:root {
  --bg: #0b0f17;
  --panel: rgba(129, 162, 255, 0.06);
  --panel-solid: #121826;
  --border: #26314a;
  --border-soft: #1b2334;
  --text: #e9edf7;
  --text-dim: #93a0bd;
  --text-faint: #5c6785;
  --accent: #4f8bff;
  --accent-bright: #7db0ff;
  --accent-strong: #2f6fed;
  --accent-soft: rgba(79, 139, 255, 0.14);
  --accent-glow: rgba(79, 139, 255, 0.28);
  --danger: #f0787c;
  --danger-soft: rgba(240, 120, 124, 0.12);
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(60rem 30rem at 15% -10%, rgba(79, 139, 255, 0.10), transparent 60%),
    radial-gradient(40rem 24rem at 100% 0%, rgba(79, 139, 255, 0.06), transparent 55%);
  background-repeat: no-repeat;
  min-height: 100vh;
}

::selection {
  background: var(--accent-strong);
  color: #fff;
}

.page {
  max-width: 55rem;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header / nav — mirrors pacoweb's header pattern */
#main-header {
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  padding: 0 0.25rem;
}

#main-header nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

@media (min-width: 768px) {
  #main-header nav {
    flex-direction: row;
    align-items: center;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
}

.brand-mark {
  font-size: 1.25rem;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  font-size: 0.875rem;
}

.nav-links a {
  color: var(--text-dim);
  text-decoration: none;
  opacity: 0.8;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.nav-links a:hover {
  opacity: 1;
  color: var(--accent-bright);
}

.nav-links a.active {
  opacity: 1;
  color: var(--text);
}

/* Terminal card */
.terminal {
  background: linear-gradient(180deg, var(--panel-solid), #0e1420);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 0 0 1px rgba(79, 139, 255, 0.04), 0 20px 60px -30px rgba(79, 139, 255, 0.35);
  overflow: hidden;
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.015);
}

.dots {
  display: flex;
  gap: 0.4rem;
}

.dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  display: inline-block;
}

.dot-red { background: #ef4444; }
.dot-yellow { background: #eab308; }
.dot-green { background: #22c55e; }

.terminal-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
}

.terminal-body {
  padding: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.terminal-footer {
  padding: 0.65rem 1.25rem;
  border-top: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.015);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
}

.prompt {
  color: var(--accent-bright);
  font-weight: 600;
}

/* Setup screen */
.setup-lead {
  color: var(--text-dim);
  line-height: 1.6;
  margin: 0 0 1.25rem;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-label {
  font-size: 0.75rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input[type="text"] {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.5;
  cursor: pointer;
}

.field-check input[type="checkbox"] {
  margin-top: 0.2rem;
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.btn-primary {
  align-self: flex-start;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 8px 20px -8px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.error-line {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(240, 120, 124, 0.25);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  font-size: 0.8rem;
  margin: 0;
}

/* Chat screen */
.chat-screen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 55vh;
  min-height: 16rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.messages::-webkit-scrollbar {
  width: 8px;
}

.messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
}

.msg {
  display: flex;
  gap: 0.6rem;
  max-width: 85%;
  animation: rise 0.18s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-bot {
  align-self: flex-start;
}

.msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  background: var(--accent-soft);
}

.msg-user .msg-avatar {
  background: rgba(255, 255, 255, 0.06);
}

.msg-bubble {
  padding: 0.6rem 0.85rem;
  border-radius: 12px;
  line-height: 1.55;
  font-size: 0.88rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-bot .msg-bubble {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  color: var(--text);
  border-top-left-radius: 4px;
}

.msg-user .msg-bubble {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #fff;
  border-top-right-radius: 4px;
}

.msg-pending .msg-bubble {
  color: var(--text-faint);
}

/* the three dots after "Thinking" take turns fading in and out */
.thinking-dot {
  animation: thinking-blink 1.2s infinite both;
}

.thinking-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes thinking-blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .thinking-dot {
    animation: none;
  }
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.5rem 0.5rem 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chat-form input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.chat-form input::placeholder {
  color: var(--text-faint);
}

.chat-form .btn-primary {
  align-self: center;
  padding: 0.5rem 1rem;
}

/* Help page */
.help-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.help-body {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-dim);
}

.help-body h1 {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: var(--text);
  margin: 0 0 0.6rem;
}

.help-body h2 {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text);
  margin: 0 0 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.help-body p {
  margin: 0 0 1rem;
}

.help-body p:last-child {
  margin-bottom: 0;
}

.feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.feature-list li {
  display: flex;
  gap: 0.75rem;
}

.feature-icon {
  flex-shrink: 0;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 8px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.feature-name {
  color: var(--text);
  font-weight: 600;
  display: block;
  margin-bottom: 0.2rem;
}

.badge-start {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.chip {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-bright);
  background: var(--accent-soft);
  border: 1px solid rgba(79, 139, 255, 0.22);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
}

.tip-list, .limit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tip-list li, .limit-list li {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}

.tip-list li::before {
  content: "→";
  color: var(--accent-bright);
  flex-shrink: 0;
}

.limit-list li::before {
  content: "!";
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: rgba(245, 179, 92, 0.16);
  color: #f5b35c;
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.15rem;
}

.help-cta {
  display: inline-flex;
  margin-top: 0.4rem;
}

.disclaimer {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.75rem;
  margin: 1.25rem 0 3rem;
}

[hidden] {
  display: none !important;
}
