:root {
  --bg: #07070b;
  --surface: #12121c;
  --surface-2: #1a1a2a;
  --line: #2a2a40;
  --ink: #f5f5fa;
  --text: #b9b9d0;
  --muted: #8383a3;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-glow: rgba(139, 92, 246, 0.35);
  --radius: 14px;
}

* { box-sizing: border-box; }

html { min-height: 100%; color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3 {
  font-family: "Sora", "Inter", system-ui, sans-serif;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
}

a { color: var(--ink); }

input, select, textarea, button { font: inherit; }

input, select, textarea {
  width: 100%;
  padding: 14px 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

input::placeholder { color: var(--muted); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

button { cursor: pointer; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* 3D background: floating shapes, math symbols, AI brain */
.bg3d {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--bg);
}
.bg3d-still, .bg3d-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.bg3d-still { object-fit: cover; }

/* Backdrop glow: darkens the middle so text stays readable over the rain */
.glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(48vmax 34vmax at 50% 46%, rgba(7, 7, 11, 0.82), transparent 75%),
    radial-gradient(60vmax 40vmax at 50% 38%, rgba(109, 40, 217, 0.18), transparent 70%);
}

body:has(.legal) .bg3d { opacity: 0.4; }

.sources {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sources[hidden] { display: none; }
.sources a {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
}
.sources a:hover { border-color: var(--accent); color: var(--ink); }
.sources-label { margin: 18px 0 0; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

.legal { text-shadow: 0 0 12px #07070b, 0 0 24px #07070b; }
.legal h3 { font-size: 1.05rem; margin: 20px 0 6px; font-weight: 700; }
.legal ul { margin: 0 0 1em; padding-left: 1.2em; }
.legal li { margin-bottom: 6px; }

.page {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px 40px;
  text-align: center;
}

.stage { width: 100%; max-width: 760px; }

/* Orb */
.orb {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 22px;
  border: 0;
  padding: 0;
  background: transparent;
  display: block;
  transition: transform 0.25s ease;
}

.orb:hover { transform: scale(1.05); }

.orb svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.6)); }
.robot-bolt { filter: drop-shadow(0 0 4px #1e40af); }
.robot-ball { filter: drop-shadow(0 0 4px #1e40af); }
.robot-eye { transform-box: fill-box; transform-origin: center; }
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.08); }
}
@media (prefers-reduced-motion: no-preference) {
  .robot-eye { animation: blink 5s ease-in-out infinite; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.14); opacity: 0.2; }
}

.eyebrow {
  display: block;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.hero-title {
  font-weight: 800;
  font-size: clamp(2rem, 5.5vw, 3.25rem);
  line-height: 1.08;
}

/* Ask form */
.ask {
  margin: 32px auto 0;
  max-width: 640px;
  text-align: left;
}

.ask-row {
  display: flex;
  gap: 10px;
}

.ask-row input {
  flex: 1;
  min-width: 0;
  padding: 16px 20px;
  border-radius: 999px;
  font-size: 17px;
}

.btn {
  min-height: 48px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  transition: background 0.2s ease, transform 0.2s ease;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.6; cursor: wait; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn-ghost:hover { background: var(--surface-2); }

altcha-widget {
  display: block;
  margin: 14px 0 0;
  color-scheme: dark;
  --altcha-color-base: var(--surface);
  --altcha-color-base-content: var(--ink);
  --altcha-border-color: var(--line);
  --altcha-border-radius: 12px;
  --altcha-max-width: 100%;
}

.form-error {
  margin: 12px 0 0;
  min-height: 1.2em;
  font-size: 15px;
  color: #fca5a5;
}

.ask-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.tool-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 14px; cursor: pointer; }
.tool-btn:hover, .tool-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); }
.tool-btn[aria-pressed="true"] { background: var(--surface-2); }
.file-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 6px 6px 6px 14px; border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: 14px; }
.file-chip { padding-left: 6px; }
.file-chip .chip-thumb { width: 36px; height: 36px; flex: none; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.file-chip .chip-thumb[hidden] { display: none; }
.file-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.file-chip button { width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--line); color: var(--ink); line-height: 1; }
.welcome-back { margin: 22px auto 0; font-size: 15px; color: var(--text); }
.welcome-back button { margin-left: 6px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 14px; }
.welcome-back button:hover { border-color: var(--accent); }
.answer-body sup.cite { margin-left: 2px; font-size: 0.72em; font-weight: 500; color: #c4b5fd; }
.answer-body pre { margin: 0 0 1em; padding: 14px 16px; overflow-x: auto; background: #07070b; border: 1px solid var(--line); border-radius: 12px; }
.answer-body pre code { padding: 0; background: none; font-size: 14px; color: #dcdcec; white-space: pre; }

/* Suggestions */
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.chip {
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.chip:hover { background: var(--surface-2); color: var(--ink); border-color: var(--accent); }

.tagline { margin: 36px 0 0; font-size: 15px; color: var(--muted); }

/* Answer */
.answer {
  max-width: 720px;
  margin: 0 auto;
  text-align: left;
}

.answer[hidden], [hidden] { display: none !important; }

.answer-q {
  font-weight: 800;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  margin-bottom: 20px;
}

.answer-body {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.answer-body p { margin: 0 0 1em; color: #dcdcec; }
.answer-body p:last-child { margin-bottom: 0; }

.answer-body.is-loading p {
  color: var(--muted);
  animation: fade 1.4s ease-in-out infinite;
}

@keyframes fade { 50% { opacity: 0.4; } }

.answer-note { margin: 14px 0 0; font-size: 14px; color: var(--muted); }

.answer-actions { margin-top: 24px; display: flex; gap: 10px; flex-wrap: wrap; }

/* Games link (top right of every page) */
.games-link {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(18, 18, 28, 0.85);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.games-link.about-link { right: 138px; min-height: 34px; width: 34px; padding: 0; justify-content: center; top: 21px; }
.games-link.social-link { top: 68px; }
.post .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.act { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); font-size: 14px; }
.act:hover { border-color: var(--accent); color: var(--ink); }
.act.on { background: var(--surface-2); border-color: var(--accent); color: #c4b5fd; }
.act.del { margin-left: auto; }
.act.del:hover { border-color: #f87171; color: #fca5a5; }
.replies { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.reply { padding: 10px 12px; background: var(--surface-2); border-radius: 12px; }
.reply .meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.reply .meta b { color: #c4b5fd; font-weight: 500; }
.reply p { margin: 0; font-size: 15px; color: #dcdcec; overflow-wrap: anywhere; white-space: pre-wrap; }
.link-del { margin-top: 4px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 12px; text-decoration: underline; }
.link-del:hover { color: #fca5a5; }
.reply-form { display: flex; flex-wrap: wrap; gap: 8px; }
.reply-form input { flex: 1; min-width: 0; padding: 10px 14px; border-radius: 999px; }
.reply-form .btn { min-height: 42px; padding: 0 18px; }
.reply-form .form-error { flex-basis: 100%; margin: 0; min-height: 0; font-size: 13px; }
.post.hl { border-color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; margin: 0; max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--accent); color: var(--ink); font-size: 14px; overflow-wrap: anywhere; }
.games-link.about-link span { display: none; }
.games-link.about-link svg { width: 18px; height: 18px; }

/* Community page */
.community { position: relative; z-index: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 0 20px 24px; flex: 1; }
.c-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 0; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.c-nav a.brand { font-family: "Sora", sans-serif; font-weight: 800; color: var(--ink); text-decoration: none; }
.c-nav .me { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.c-nav .me b { color: var(--ink); font-weight: 500; }
.c-nav .btn { min-height: 34px; padding: 0 16px; font-size: 14px; }
.composer textarea { min-height: 96px; resize: vertical; }
.composer .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
.composer .count { font-size: 13px; color: var(--muted); }
.feed { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 12px; }
.post { padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.post .meta { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.post .meta b { color: #c4b5fd; font-weight: 500; }
.post p { margin: 0; color: #dcdcec; white-space: pre-wrap; overflow-wrap: anywhere; }
.feed .empty { color: var(--muted); text-align: center; padding: 24px 0; }
.composer .note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.badge { display: inline-block; margin-top: 10px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; color: #c4b5fd; }
.badge.rejected, .badge.restricted { color: #fca5a5; }
.act.del-soft:hover { border-color: #f87171; color: #fca5a5; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.admin .profile { display: flex; align-items: center; gap: 16px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.admin .profile h1 { font-size: 1.4rem; }
.admin .profile p { margin: 2px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.admin .profile .meta { color: var(--muted); font-size: 13px; }
.admin .avatar { flex: none; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent); color: #fff; font-family: "Sora", sans-serif; font-weight: 800; font-size: 1.3rem; }
.admin .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 16px 0; }
.admin .stats div { padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-align: center; }
.admin .stats b { display: block; font-family: "Sora", sans-serif; font-size: 1.5rem; color: var(--ink); }
.admin .stats span { font-size: 12px; color: var(--muted); }
.admin-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.admin-tabs .tab { flex: 1; min-width: 70px; min-height: 38px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); font-size: 14px; }
.admin-tabs .tab.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.admin .profile > div:last-child { min-width: 0; }
.admin .profile h1 { overflow-wrap: anywhere; font-size: clamp(1.1rem, 4.5vw, 1.4rem); }
.admin .profile .meta { overflow-wrap: anywhere; }
.games-link:hover { border-color: var(--accent); background: var(--surface-2); }
.games-link svg { color: #a78bfa; }

.account-link {
  position: fixed; top: 16px; left: 16px; z-index: 6;
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(18, 18, 28, 0.85); color: var(--ink);
  font-size: 15px; font-weight: 500; text-decoration: none;
}
.account-link:hover { border-color: var(--accent); background: var(--surface-2); }

/* Rendered markdown in answers */
.answer-body strong { color: var(--ink); }
.answer-body ul, .answer-body ol { margin: 0 0 1em; padding-left: 1.3em; color: #dcdcec; }
.answer-body li { margin-bottom: 4px; }
.answer-body h3 { font-size: 1.05rem; margin: 0 0 8px; }
.answer-body code { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); font-size: 0.92em; }
.table-wrap { overflow-x: auto; margin: 0 0 1em; }
.answer-body table { width: 100%; border-collapse: collapse; font-size: 15px; }
.answer-body th, .answer-body td { padding: 8px 12px; border: 1px solid var(--line); text-align: left; color: #dcdcec; }
.answer-body th { background: var(--surface-2); color: var(--ink); }

/* Auth pages */
.auth { position: relative; z-index: 1; flex: 1; display: flex; align-items: center; justify-content: center; padding: 72px 20px 24px; }
.auth-card { width: 100%; max-width: 420px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4); }
.auth-card h1 { font-size: 1.8rem; margin-bottom: 18px; }
.auth-card label { display: block; margin: 14px 0 6px; font-size: 14px; color: var(--muted); }
.auth-card .btn { width: 100%; margin-top: 18px; }
.auth-card .alt { margin: 16px 0 0; font-size: 15px; color: var(--muted); }
.auth-card .alt a { color: var(--ink); }
.auth-card .ok { color: #86efac; margin: 12px 0 0; }

/* Footer */
.site-footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding: 24px 20px 28px;
  font-size: 14px;
  color: var(--muted);
}

.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover, .site-footer a.active { color: var(--ink); }

/* Cookie banner */
.cookie {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px 32px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
}

.cookie-text { flex: 1; font-size: 14px; line-height: 1.55; }
.cookie-text strong { display: block; color: var(--ink); margin-bottom: 4px; font-size: 15px; }
.cookie-text p { margin: 0; }
.cookie-actions { display: flex; gap: 10px; flex-shrink: 0; }
.cookie .btn { min-height: 42px; padding: 0 20px; }

html.consent-set .cookie { display: none; }
html:not(.consent-set) body { padding-bottom: 120px; }
@media (max-width: 640px) { html:not(.consent-set) body { padding-bottom: 170px; } }

/* Legal pages */
.legal {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 72px 20px 24px;
  flex: 1;
}

.legal h1 { font-weight: 800; font-size: clamp(2rem, 5vw, 2.75rem); margin-bottom: 8px; }
.legal h2 { font-size: 1.25rem; margin: 32px 0 8px; font-weight: 700; }
.legal p { margin: 0 0 1em; }
.legal .back { display: inline-block; margin-bottom: 24px; font-size: 15px; color: var(--muted); text-decoration: none; }
.legal .back:hover { color: var(--ink); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .page { padding-top: 40px; justify-content: flex-start; }
  .ask-row { flex-direction: column; }
  .ask-row .btn { width: 100%; }
  .cookie { flex-direction: row; align-items: center; gap: 10px; padding: 8px 12px; }
  .cookie-text { font-size: 11.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .cookie-text strong { display: none; }
  .cookie .btn { min-height: 32px; padding: 0 12px; font-size: 13px; }
  .cookie-actions { flex-direction: column; gap: 6px; }
  html:not(.consent-set) body { padding-bottom: 96px; }
}

@media (prefers-reduced-motion: no-preference) {
  html.js-motion [data-animate="hero"],
  html.js-motion [data-animate="split"],
  html.js-motion [data-animate="stagger"] > * { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .orb::after, .answer-body.is-loading p { animation: none; }
  * { transition: none !important; }
}
