:root {
  --bg: #0b0f14;
  --panel: #0f1620;
  --text: #e6edf3;
  --muted: rgba(230,237,243,.75);
  --border: #1f2a36;
  --link: #9cc2ff;
  --primary: #22c55e;
  --user: #1d4ed8;
  --bot: #243244;
}

[data-theme="light"] {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #0b0f14;
  --muted: rgba(11,15,20,.70);
  --border: #d8dde6;
  --link: #245bdb;
  --primary: #16a34a;
  --user: #245bdb;
  --bot: #eef2f7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none; }

.topbar {
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:16px 20px;
  border-bottom:1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.brand { font-weight: 800; letter-spacing: 0.02em; }

.link { color: var(--link); text-decoration:none; font-weight: 600; }

.container { max-width: 980px; margin: 0 auto; padding: 24px 16px; }

.landing {
  padding: 56px 22px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.landing::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: color-mix(in srgb, var(--primary) 70%, var(--link));
  opacity: 0.7;
}

.hero-title {
  margin: 0 0 12px 0;
  font-size: 3.4rem;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  margin: 0 auto 22px auto;
  max-width: 70ch;
  opacity: 0.92;
  line-height: 1.55;
  font-size: 1.05rem;
}

.hero-typed {
  margin: 0 auto 18px auto;
  min-height: 1.6rem;
  max-width: 72ch;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.caret {
  display: inline-block;
  width: 0.6ch;
  animation: blink 1s step-end infinite;
}

.hero-highlights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 auto 18px auto;
  max-width: 900px;
}

.highlight-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bot) 55%, transparent);
  padding: 12px;
  text-align: left;
}

.highlight-title {
  font-size: 0.88rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.highlight-text {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.35;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.primary {
  padding: 12px 18px;
  border-radius: 12px;
  border: 0;
  background: var(--primary);
  font-weight: 800;
  cursor: pointer;
  color: #0b0f14;
}

.secondary {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--link);
  text-decoration: none;
  font-weight: 700;
}

.hero-footnote {
  margin: 10px auto 0 auto;
  opacity: 0.75;
  max-width: 85ch;
  font-size: 0.95rem;
}

.chat-screen { padding-top: 6px; }

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

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

.chat-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.chat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-tab {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.chat-tab:hover {
  border-color: color-mix(in srgb, var(--link) 55%, var(--border));
}

.chat-tab.active {
  border-color: var(--link);
  color: var(--link);
  background: color-mix(in srgb, var(--link) 15%, transparent);
}

.chat-tab:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--link) 70%, transparent);
  outline-offset: 2px;
}

.chat-badge {
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.95rem;
  opacity: 0.95;
}

.audience-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.audience-label {
  color: var(--muted);
  font-size: 0.92rem;
  margin-right: 2px;
}

.audience-chip,
.mode-chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.audience-chip:hover,
.mode-chip:hover {
  border-color: color-mix(in srgb, var(--link) 55%, var(--border));
}

.audience-chip:focus-visible,
.mode-chip:focus-visible,
.example-chip:focus-visible,
.attachment-link:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--link) 70%, transparent);
  outline-offset: 2px;
}

.audience-chip.is-active,
.mode-chip.is-active {
  border-color: var(--link);
  color: var(--link);
  background: color-mix(in srgb, var(--link) 15%, transparent);
}

.chat {
  height: 65vh;
  overflow:auto;
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  background: var(--panel);
}

.bubble {
  padding:10px 12px;
  border-radius:12px;
  margin:8px 0;
  max-width: 78%;
  line-height: 1.35;
  white-space: pre-wrap;
}

.user { margin-left:auto; background: var(--user); color: #fff; }
.bot { margin-right:auto; background: var(--bot); color: var(--text); }

.bot .md-content {
  white-space: normal;
}

.bot .md-content > :first-child {
  margin-top: 0;
}

.bot .md-content > :last-child {
  margin-bottom: 0;
}

.bot .md-content h1,
.bot .md-content h2,
.bot .md-content h3,
.bot .md-content h4 {
  margin: 0.45rem 0 0.35rem;
  line-height: 1.25;
}

.bot .md-content p {
  margin: 0.35rem 0;
}

.bot .md-content ul,
.bot .md-content ol {
  margin: 0.35rem 0;
  padding-left: 1.15rem;
}

.bot .md-content li + li {
  margin-top: 0.2rem;
}

.bot .md-content code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92em;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--bg) 40%, transparent);
}

.bot .md-content pre {
  margin: 0.45rem 0;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  overflow-x: auto;
}

.bot .md-content pre code {
  background: transparent;
  padding: 0;
  font-size: 0.9em;
}

.bot .md-content a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bot .md-content a:hover {
  opacity: 0.9;
}

.composer { display:flex; gap:10px; margin-top:12px; }

input {
  flex:1;
  padding:12px;
  border-radius:12px;
  border:1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

button {
  padding:12px 16px;
  border-radius:12px;
  border:0;
  background: var(--primary);
  font-weight:800;
  cursor:pointer;
  color: #0b0f14;
}

.ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
}

.mode-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode-title {
  color: var(--muted);
  font-size: 0.92rem;
}

.mode-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.examples-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.examples-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.examples-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.example-chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 100%;
  text-align: left;
}

.example-chip:hover {
  border-color: var(--link);
  color: var(--link);
  background: color-mix(in srgb, var(--link) 8%, transparent);
}

.attachment-row {
  margin: 6px 0 12px 0;
}

.attachment-link {
  color: var(--link);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.attachment-link:hover {
  border-bottom-color: currentColor;
}

.loading-bubble {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.loading-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, var(--text) 20%, transparent);
  border-top-color: var(--link);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.loading-text {
  opacity: 0.85;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}


.hint { margin-top: 10px; opacity: 0.75; font-size: 0.95rem; }

@media (max-width: 700px) {
  .chat-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .landing {
    padding: 38px 16px;
  }

  .hero-title {
    font-size: 2.5rem;
  }

  .hero-highlights {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .chat-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .mode-toggle,
  .chat-tabs,
  .audience-row,
  .examples-list {
    gap: 6px;
  }

  .chat-tabs-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .audience-chip,
  .mode-chip,
  .example-chip {
    font-size: 0.85rem;
    padding: 6px 10px;
  }

  .chat {
    height: 60vh;
  }
}
