/* Shared palette. Legacy gold/violet names remain aliases for existing components. */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f4ef; --bg-rgb: 245,244,239;
  --surface: #ffffff; --surface-rgb: 255,255,255;
  --surface-2: #edf2ee; --surface-2-rgb: 237,242,238;
  --surface-3: #e3ece7; --surface-3-rgb: 227,236,231;
  --text: #203335; --text-rgb: 32,51,53;
  --muted: #607174; --muted-rgb: 96,113,116;
  --primary: #146f68; --primary-rgb: 20,111,104;
  --on-primary: #ffffff; --on-primary-rgb: 255,255,255;
  --coral: #b94f3b; --coral-rgb: 185,79,59;
  --line: #d8e2de; --line-rgb: 216,226,222;
  --danger: #ad3434; --success: #26704c;
  --shadow: 0 16px 48px rgba(32,51,53,.08);
  --user-bg: #146f68; --user-text: #ffffff;
  --star-opacity: .18; --halo-opacity: .08;
  --gold: var(--primary); --gold-soft: rgba(var(--primary-rgb),.10);
  --violet: var(--coral); --color-accent: var(--primary);
  --color-bg: var(--bg); --color-surface: var(--surface);
  --color-text: var(--text); --color-muted: var(--muted); --border-color: var(--line);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101c1d; --bg-rgb: 16,28,29;
  --surface: #19292b; --surface-rgb: 25,41,43;
  --surface-2: #203335; --surface-2-rgb: 32,51,53;
  --surface-3: #294043; --surface-3-rgb: 41,64,67;
  --text: #edf4f2; --text-rgb: 237,244,242;
  --muted: #a5b8b7; --muted-rgb: 165,184,183;
  --primary: #73d3c1; --primary-rgb: 115,211,193;
  --on-primary: #102c29; --on-primary-rgb: 16,44,41;
  --coral: #f29a83; --coral-rgb: 242,154,131;
  --line: #304547; --line-rgb: 48,69,71;
  --danger: #ffaaaa; --success: #90dbb0;
  --shadow: 0 20px 64px rgba(0,0,0,.22);
  --user-bg: #28554f; --user-text: #edf4f2;
  --star-opacity: .55; --halo-opacity: .14;
}
html { background: var(--bg); }
body, body.auth-page, body.profile-page, body.coffee-page { background: var(--bg); color: var(--text); isolation: isolate; }
body::before { content: none; }
::selection { color: var(--text); background: rgba(var(--primary-rgb),.22); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.topbar, .landing-nav { background: rgba(var(--bg-rgb),.94); border-color: var(--line); }
.brand-mark { background: var(--primary); color: var(--on-primary); box-shadow: 0 0 24px rgba(var(--primary-rgb),.18); }
.topbar { height: auto; min-height: 72px; gap: 20px; padding-block: 12px; }
.topbar-actions { flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.theme-control { display: inline-flex; align-items: center; flex: 0 0 auto; gap: 7px; color: var(--muted); font-size: .75rem; white-space: nowrap; }
.theme-control select { min-height: 36px; max-width: 94px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; }
.wallet-button { border-color: rgba(var(--primary-rgb),.32); background: var(--gold-soft); }
.primary-button, .send-button, .chart-open, .chart-profile-cta, .mode-button.is-active,
.landing-nav .nav-cta, .assistant-avatar, .assistant-turn .turn-avatar { background: var(--primary); color: var(--on-primary); }
.user-turn .turn-avatar { color: var(--user-text); background: var(--user-bg); }
.user-message, .user-message::after { background: var(--user-bg); color: var(--user-text); }
.assistant-message, .assistant-message.welcome-message, .open-reading-message,
.chart-card, .chart-dialog .chart-card, .auth-card, .profile-card, .reading-showcase article {
  background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: var(--shadow);
}
.assistant-message::after { background: var(--surface); }
.welcome-message > p, .reading-choice legend { color: var(--text); }
.composer, .composer textarea, .chart-dialog, .chart-media-viewer, .relationship-image-dialog { background: var(--surface); color: var(--text); }
.chart-carousel figure { background: radial-gradient(circle, var(--surface-2), var(--surface)); }
.chart-carousel-timing, .chart-carousel-dots button { color: var(--muted); }
.planet-label, .carousel-transit-planet { fill: var(--text); filter: none; }
.planet-halo, .carousel-transit-halo { fill: var(--surface); }
.house-label { fill: var(--muted); }
.chart-ring.inner, .zodiac-line { stroke: rgba(var(--text-rgb),.22); }
:root[data-theme="light"] .aspect-harmonious { stroke: #287765; }
:root[data-theme="light"] .aspect-dynamic { stroke: #b74956; }
:root[data-theme="light"] .aspect-neutral { stroke: #786098; }
/* More breathing room, without increasing the fixed viewport on mobile. */
.messages { gap: 28px; padding: 18px 12px 32px; }
.message { padding: 22px 24px; max-width: min(86%, 720px); line-height: 2.15; overflow-wrap: anywhere; }
.assistant-message.welcome-message { padding: 26px; }
.conversation-heading { padding-block: 16px; margin-bottom: 18px; }
.topic-panel { padding-inline-end: 18px; }
.suggested-questions { gap: 11px; }
.chart-launcher { padding: 14px 18px; margin-bottom: 12px; background: var(--surface); }
.profile-card, .auth-card { padding: clamp(24px,4vw,42px); }
.landing-page .landing-shell { padding-block: 80px; gap: clamp(40px,6vw,90px); }
.landing-proof { gap: 20px; }
.landing-section { padding-block: clamp(80px,10vw,140px); }
.coffee-page { --coffee-copper: var(--coral); --coffee-cream: var(--text); --coffee-border: var(--line); }
.cup-panel, .coffee-conversation, .coffee-intention-card { background: var(--surface); }
.composer-border-glow .glow-point { fill: var(--primary); }
/* Atmosphere stays behind content, never intercepts input, and uses just two animated halos. */
.celestial-sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; contain: strict; }
.celestial-sky::before, .celestial-sky::after { content: ''; position: absolute; width: min(70vw,800px); aspect-ratio: 1; border-radius: 50%; opacity: var(--halo-opacity); background: radial-gradient(circle, var(--primary), transparent 65%); animation: sky-drift 42s ease-in-out infinite alternate; }
.celestial-sky::before { top: -25%; right: -18%; }
.celestial-sky::after { bottom: -35%; left: -22%; background: radial-gradient(circle, var(--coral), transparent 65%); animation-duration: 58s; animation-direction: alternate-reverse; }
.celestial-sky i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: var(--primary); opacity: var(--star-opacity); box-shadow: 0 0 8px 1px rgba(var(--primary-rgb),.35); }
.celestial-sky i:nth-child(3n) { width: 3px; height: 3px; }
.celestial-sky i:nth-child(5n) { background: var(--coral); animation: sky-twinkle 12s ease-in-out infinite alternate; }
.chat-page .celestial-sky { opacity: .5; }
.celestial-sky.is-paused *, .celestial-sky.is-paused::before, .celestial-sky.is-paused::after { animation-play-state: paused; }
@keyframes sky-drift { to { transform: translate(3vw,4vh); } }
@keyframes sky-twinkle { from { opacity: calc(var(--star-opacity) * .35); } to { opacity: var(--star-opacity); } }
@media (min-width: 881px) {
  .chat-page .app-shell { height: 100dvh; min-height: 0; display: flex; flex-direction: column; }
  .chat-page .topbar { flex: 0 0 auto; }
  .chat-page .workspace { flex: 1; height: auto; min-height: 0; padding-block: 24px; gap: 40px; }
}
@media (max-width: 880px) {
  .theme-control > span { display: none; }
  .landing-nav nav { gap: 12px; }
  .topic-panel { padding-inline-end: 0; }
  .messages { gap: 20px; padding: 12px 8px 24px; }
  .message, .assistant-message.welcome-message { padding: 17px 18px; }
  .landing-page .landing-shell { padding-block: 48px; }
}
@media (max-width: 620px) {
  .topbar { gap: 8px; padding-inline: 12px; }
  .topbar-actions { gap: 6px; }
  .theme-control select { font-size: .7rem; min-height: 32px; padding-inline: 4px; }
  .landing-nav nav { gap: 7px; }
  .landing-nav .nav-cta { font-size: .65rem; padding: 8px; }
  .landing-nav .brand { font-size: .88rem; }
  .message { max-width: calc(100% - 36px); }
  .messages { padding-inline: 4px; gap: 18px; }
  .profile-card, .auth-card { padding: 22px; }
  .celestial-sky i:nth-child(n+11) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .celestial-sky *, .celestial-sky::before, .celestial-sky::after, .orbit-art, .orbit-art * { animation: none !important; }
}
.celestial-sky i:nth-child(1) { left: 4%; top: 13%; }
.celestial-sky i:nth-child(2) { left: 16%; top: 44%; }
.celestial-sky i:nth-child(3) { left: 9%; top: 75%; }
.celestial-sky i:nth-child(4) { left: 24%; top: 90%; }
.celestial-sky i:nth-child(5) { left: 35%; top: 8%; }
.celestial-sky i:nth-child(6) { left: 49%; top: 26%; }
.celestial-sky i:nth-child(7) { left: 62%; top: 5%; }
.celestial-sky i:nth-child(8) { left: 77%; top: 19%; }
.celestial-sky i:nth-child(9) { left: 94%; top: 36%; }
.celestial-sky i:nth-child(10) { left: 86%; top: 61%; }
.celestial-sky i:nth-child(11) { left: 95%; top: 85%; }
.celestial-sky i:nth-child(12) { left: 73%; top: 93%; }
.celestial-sky i:nth-child(13) { left: 56%; top: 79%; }
.celestial-sky i:nth-child(14) { left: 39%; top: 67%; }
.celestial-sky i:nth-child(15) { left: 19%; top: 62%; }
.celestial-sky i:nth-child(16) { left: 6%; top: 94%; }
.celestial-sky i:nth-child(17) { left: 92%; top: 9%; }
.celestial-sky i:nth-child(18) { left: 67%; top: 47%; }

.topbar-actions { min-width: 0; }
.topbar .brand { flex-shrink: 0; }
.chart-launcher strong { white-space: normal; }
.coffee-chat-page { --cream: var(--text); }
:root { --accent: var(--coral); --border: var(--line); }
/* Motion-sensitive users keep the sky still and dialogs appear immediately. */
@media (prefers-reduced-motion: reduce) { .chart-dialog[open] { animation: none; } }

/* Header controls: compact theme cycle and a shared navigation disclosure. */
.header-tools { position: relative; display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.theme-toggle, .header-menu-toggle { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.theme-toggle { min-width: 96px; gap: 6px; padding: 8px 12px; font-size: .8rem; white-space: nowrap; }
.header-menu-toggle { width: 44px; padding: 8px; font-size: 1.3rem; line-height: 1; }
.header-menu-toggle[aria-expanded="true"] { border-color: var(--primary); color: var(--primary); background: var(--gold-soft); }
.header-menu { position: absolute; inset-inline-end: 0; top: calc(100% + 14px); width: min(290px,calc(100vw - 28px)); max-height: min(70dvh,580px); overflow-y: auto; padding: 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); z-index: 100; }
.header-menu .topbar-actions, .landing-nav .header-menu nav { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 8px; width: 100%; }
.topbar .header-menu a, .topbar .header-menu button, .landing-nav .header-menu nav a { display: flex; align-items: center; justify-content: flex-start; width: 100%; min-height: 44px; padding: 11px 14px; border-radius: 10px; text-align: start; color: var(--text); background: var(--surface-2); font-size: .82rem; text-decoration: none; white-space: normal; }
.topbar .header-menu .wallet-button { color: var(--primary); gap: 5px; }
.topbar .header-menu .connection-status { display: block; padding: 8px 12px; }
.header-menu a:hover, .header-menu button:hover { background: var(--gold-soft); }
.landing-nav.has-header-menu { display: flex; grid-template-columns: none; justify-content: space-between; }
@media (max-width: 620px) {
  .header-tools { gap: 7px; }
  .theme-toggle { min-width: 86px; padding: 8px; font-size: .76rem; }
  .topbar.has-header-menu { min-height: 64px; flex-wrap: nowrap; }
  .header-menu { top: calc(100% + 10px); }
}
