:root {
  color-scheme: dark;
  --bg: #050505;
  --text: #f5f5f2;
  --muted: #9d9d99;
  --line: #292929;
  --focus: #ded7bd;
  --max: 900px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif; font-size: 15px; line-height: 1.6; }
.topbar { height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-inline: clamp(16px, 3vw, 30px); border-bottom: 1px solid #151515; }
.topbar img { height: 20px; max-width: 180px; }
.wrap { width: min(100% - 32px, var(--max)); margin-inline: auto; padding: clamp(16px, 3vw, 28px) 0 max(28px, env(safe-area-inset-bottom)); }
.hero { padding: 8px 10px 18px; text-align: center; }
.eyebrow { color: #aaa; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.hero h1 { margin: 8px 0; font-size: clamp(23px, 3vw, 34px); font-weight: 620; line-height: 1.18; }
.hero p { max-width: 640px; margin: 0 auto; color: var(--muted); font-size: clamp(13px, 1.2vw, 15px); }
.chat-shell { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(180deg, #0c0c0c, #070707); }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chat-head h2 { margin: 0 0 2px; font-size: clamp(15px, 1.2vw, 17px); line-height: 1.3; }
.chat-head p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.chat-title-copy { display: none; }
.chat-head { position: absolute; top: 8px; right: 8px; z-index: 1; justify-content: flex-end; padding: 0; border: 0; }
.ghost { min-height: 36px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 11px; background: transparent; color: var(--muted); font-size: 12px; }
.member-control { min-width: 44px; min-height: 36px; display: grid; place-items: center; }
.member-login, .member-menu summary, .member-menu button { min-height: 36px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); font: inherit; font-size: 12px; text-decoration: none; }
.member-login { display: inline-grid; place-items: center; padding: 6px 12px; }
.member-menu { position: relative; }
.member-menu summary { display: flex; align-items: center; gap: 7px; max-width: min(44vw, 220px); padding: 4px 8px 4px 5px; cursor: pointer; list-style: none; }
.member-menu summary::-webkit-details-marker { display: none; }
.member-avatar { width: 24px; height: 24px; display: grid; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 11px; }
.member-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-menu button { position: absolute; top: calc(100% + 6px); right: 0; z-index: 3; padding: 6px 12px; cursor: pointer; }
.member-login:hover, .member-menu summary:hover, .member-menu button:hover { background: rgba(255,255,255,.04); }
.chat-log { min-height: min(48dvh, 420px); max-height: 56dvh; overflow: auto; overscroll-behavior: contain; padding: 16px; }
.message { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.message.user { align-items: flex-end; }
.role { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.bubble { max-width: min(82%, 660px); padding: 10px 12px; overflow-wrap: anywhere; word-break: break-word; border: 1px solid var(--line); border-radius: 14px; background: #111; line-height: 1.6; white-space: pre-wrap; }
.user .bubble { border-color: #f1f1ee; background: #f1f1ee; color: #111; }
.quick-area { padding: 0 16px 12px; }
.quick-label { margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.quick-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.quick-row::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; background: #0d0d0d; color: var(--text); font-size: 12px; line-height: 1.35; white-space: nowrap; }
.composer { display: grid; grid-template-columns: minmax(0, 1fr) 44px 44px; gap: 8px; padding: 12px 14px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #0d0d0d; }
.composer input { width: 100%; min-width: 0; height: 44px; border: 1px solid var(--line); border-radius: 13px; padding: 0 12px; outline: none; background: #111; color: var(--text); font: inherit; font-size: 16px; }
.round, .send { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 50%; cursor: pointer; font-size: 19px; }
.round { border: 1px solid var(--line); background: transparent; color: var(--text); box-shadow: none; }
.round:hover { background: rgba(255, 255, 255, .04); }
.send { border: 0; background: #f1f1ee; color: #111; font-size: 22px; }
.ai-disclaimer { margin: 6px 12px max(10px, env(safe-area-inset-bottom)); color: var(--muted); font-size: 11px; line-height: 1.45; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.composer input:focus-visible, .ghost:focus-visible, .chip:focus-visible, .round:focus-visible, .send:focus-visible, .voice-close:focus-visible, .voice-start:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.voice-dialog { max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); border: 0; padding: 0; background: transparent; color: inherit; }
.voice-dialog::backdrop { background: rgba(0, 0, 0, .8); }
.voice-panel { position: relative; width: min(390px, calc(100vw - 24px)); padding: 30px 22px max(22px, env(safe-area-inset-bottom)); border: 1px solid var(--line); border-radius: 16px; background: #0b0b0b; box-shadow: none; text-align: center; }
.voice-close { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--text); box-shadow: none; font-size: 24px; }
.voice-close:hover { background: rgba(255, 255, 255, .04); }
.orb { width: 64px; height: 64px; margin: 8px auto 16px; border: 1px solid var(--line); border-radius: 50%; background: transparent; box-shadow: none; }
.voice-start { min-height: 44px; border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px; background: transparent; color: var(--text); box-shadow: none; font-weight: 700; }
.voice-start:hover { background: rgba(255, 255, 255, .04); }

@media (min-width: 768px) { .wrap { width: min(100% - 48px, 800px); padding-top: 28px; } .chat-log { min-height: 440px; max-height: 58dvh; } .hero { padding-bottom: 22px; } .composer input { font-size: 15px; } }
@media (min-width: 1200px) { .wrap { width: min(100% - 64px, var(--max)); padding-top: 34px; } .topbar { height: 66px; } .chat-shell { border-radius: 20px; } .chat-log { padding: 18px; } .message { margin-bottom: 14px; } .bubble { padding: 11px 14px; } }
@media (max-width: 767px) { .topbar { padding-inline: 12px; } .topbar img { max-width: 150px; } .wrap { width: 100%; padding: 10px 12px max(16px, env(safe-area-inset-bottom)); } .hero { padding: 4px 4px 14px; } .hero h1 { font-size: 23px; } .chat-shell { border-radius: 14px; } .chat-head { padding: 12px; } .chat-log { min-height: calc(100dvh - 310px); max-height: 58dvh; padding: 12px; } .bubble { max-width: 92%; padding: 9px 11px; border-radius: 13px; } .quick-area { padding: 0 12px 10px; } .composer { gap: 7px; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); } .voice-panel { border-radius: 18px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }


/* Luna breathing onboarding intro v1 */
.message.assistant.luna-onboarding {
  position: relative;
  display: block;
  width: 100%;
  max-width: 760px;
  margin: 24px 0 34px;
  padding: 4px 0 4px 30px;
}

.message.assistant.luna-onboarding::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16%;
  width: 3px;
  height: 68%;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
}

.message.assistant.luna-onboarding .role {
  display: none;
}

.message.assistant.luna-onboarding .bubble,
.message.assistant.luna-onboarding .luna-onboarding-bubble {
  display: block;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  white-space: pre-line;
  color: rgba(255,255,255,.95);
  font-size: clamp(18px, 1.15vw, 20px);
  font-weight: 400;
  line-height: 1.58;
  letter-spacing: .01em;
}

@media (max-width: 760px) {
  .message.assistant.luna-onboarding {
    margin: 18px 0 28px;
    padding-left: 20px;
  }

  .message.assistant.luna-onboarding::before {
    width: 3px;
    top: 15%;
    height: 70%;
  }

  .message.assistant.luna-onboarding .bubble,
  .message.assistant.luna-onboarding .luna-onboarding-bubble {
    font-size: 18px;
    line-height: 1.6;
  }
}

/* Luna onboarding typography final */
.message.assistant.luna-onboarding .bubble.luna-onboarding-bubble {
  font-family: inherit !important;
  font-weight: 400 !important;
  font-style: normal !important;
  font-synthesis: none !important;
}

/* Luna first-turn conversation spacing v1 */
#chat-log .message.assistant.luna-onboarding {
  margin-bottom: 12px !important;
}

#chat-log .message.assistant.luna-onboarding + .message.user {
  margin-top: 8px !important;
  margin-bottom: 12px !important;
}

#chat-log .message.assistant.luna-onboarding + .message.user + .message.assistant {
  margin-top: 0 !important;
  margin-bottom: 18px !important;
}

/* Keep first exchange visually connected */
#chat-log .message.assistant.luna-onboarding + .message.user .bubble,
#chat-log .message.assistant.luna-onboarding + .message.user + .message.assistant .bubble {
  margin-top: 0 !important;
}
