:root {
  color-scheme: light;
  --ink: #29233d;
  --muted: #89849a;
  --purple: #7658d5;
  --purple-dark: #6145bd;
  --lilac: #eee9ff;
  --paper: #fff;
  --line: #ece9f2;
  --peach: #ffe9dc;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(ellipse at 18% 58%, rgba(251, 233, 255, .54), transparent 34rem),
    #f8f7fb;
  color: var(--ink);
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.shell { max-width: 1180px; min-height: 100vh; margin: auto; padding: 0 42px; }
.topbar { height: 94px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(224, 220, 234, .72); }
.brand { display: inline-flex; gap: 11px; align-items: center; color: var(--ink); text-decoration: none; font: 800 20px/1 "Manrope", sans-serif; letter-spacing: -1px; }
.brand-mark { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 14px; background: var(--purple); color: white; font-size: 23px; letter-spacing: -2px; }
.brand-accent { color: var(--purple); }
.brand small { display: block; margin-top: 5px; color: #a19bac; font: 700 8px/1 "DM Sans", sans-serif; letter-spacing: 2px; }
.topbar-note { display: flex; align-items: center; gap: 9px; color: #827c91; font-size: 12px; }
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #72c59b; box-shadow: 0 0 0 3px #e6f4ed; }

.join-layout { display: grid; grid-template-columns: 1fr 400px; gap: 95px; align-items: center; min-height: 660px; padding: 46px 8px; }
.welcome { position: relative; padding-top: 7px; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--purple); font-size: 10px; font-weight: 700; letter-spacing: 1.5px; }
.eyebrow span:last-child { font-size: 17px; }
.welcome h1 { margin: 23px 0 15px; font: 800 clamp(42px, 5vw, 61px)/1.12 "Manrope", sans-serif; letter-spacing: -3.4px; }
.welcome h1 span { color: var(--purple); }
.welcome-copy { max-width: 438px; margin: 0; color: #777188; font-size: 15px; line-height: 1.8; }
.welcome-art { position: relative; height: 185px; max-width: 440px; margin-top: 18px; overflow: hidden; }
.art-orbit { position: absolute; width: 176px; height: 176px; left: 94px; top: 17px; border: 1px dashed #d9cef8; border-radius: 50%; }
.art-orbit::after { position: absolute; content: ""; inset: 20px; border: 1px solid rgba(217, 206, 248, .53); border-radius: 50%; }
.bubble { position: absolute; z-index: 1; padding: 14px 18px; border-radius: 18px; box-shadow: 0 11px 26px rgba(58, 44, 94, .08); font-size: 14px; font-weight: 600; }
.bubble-peach { left: 28px; top: 36px; transform: rotate(-5deg); background: var(--peach); }
.bubble-peach span { margin-left: 8px; color: #ec9b6e; }
.bubble-lilac { left: 180px; top: 97px; transform: rotate(4deg); background: var(--lilac); color: #6752a8; }
.art-sparkle { position: absolute; color: #f0ad79; }
.sparkle-one { left: 305px; top: 39px; font-size: 24px; }
.sparkle-two { left: 63px; top: 124px; color: var(--purple); font-size: 16px; }
.small-note { max-width: 405px; color: #9a95a7; font-size: 10px; line-height: 1.6; }

.join-card { padding: 30px 31px 20px; border: 1px solid rgba(231, 227, 239, .8); border-radius: 20px; background: rgba(255,255,255,.92); box-shadow: 0 19px 55px rgba(61, 43, 107, .08); }
.card-icon { display: grid; width: 39px; height: 39px; place-items: center; border-radius: 13px; background: var(--lilac); color: var(--purple); font-size: 21px; }
.join-card h2 { margin: 17px 0 5px; font: 800 25px/1.2 "Manrope", sans-serif; letter-spacing: -.8px; }
.card-subtitle { margin: 0 0 25px; color: var(--muted); font-size: 12px; }
.join-card > label:not(.promise) { display: block; margin-bottom: 8px; font-size: 11px; font-weight: 700; }
.join-card > input, .join-card > select { width: 100%; height: 46px; padding: 0 13px; border: 1px solid #e8e5ee; border-radius: 9px; outline: none; background: #fcfbfe; color: var(--ink); font-size: 12px; }
.join-card > input:focus, .join-card > select:focus, .composer input:focus { border-color: #a896e9; box-shadow: 0 0 0 3px rgba(118, 88, 213, .1); }
.field-hint { margin: 7px 0 18px; color: #9a95a7; font-size: 10px; }
.promise { display: flex; align-items: flex-start; gap: 9px; color: #79738a; font-size: 10px; line-height: 1.5; cursor: pointer; }
.promise input { margin: 2px 0 0; accent-color: var(--purple); }
.primary-button { display: flex; width: 100%; height: 46px; align-items: center; justify-content: center; gap: 10px; margin-top: 19px; border: 0; border-radius: 9px; background: var(--purple); color: white; font-size: 12px; font-weight: 700; cursor: pointer; transition: background .2s, transform .2s; }
.primary-button:hover, .composer button:hover { transform: translateY(-1px); background: var(--purple-dark); }
.primary-button span { font-size: 17px; }
.error-message { min-height: 14px; margin: 9px 0 0; color: #b94555; font-size: 10px; }
.card-footer { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 15px; border-top: 1px solid var(--line); color: #a09aab; font-size: 10px; }
.card-footer span:last-child { color: #e19a9e; font-size: 14px; }

.page-footer { display: flex; justify-content: space-between; padding: 18px 0 23px; border-top: 1px solid rgba(224, 220, 234, .72); color: #9a95a7; font-size: 10px; }
.page-footer b { margin-left: 5px; color: var(--purple); }

.chat-layout { display: grid; grid-template-columns: 255px 1fr; min-height: 690px; margin: 34px 0 37px; overflow: hidden; border: 1px solid #ebe8f1; border-radius: 18px; background: var(--paper); box-shadow: 0 15px 44px rgba(61, 43, 107, .06); }
.chat-sidebar { position: relative; display: flex; flex-direction: column; padding: 24px 18px 17px; border-right: 1px solid var(--line); background: #fcfbfe; }
.sidebar-heading { display: flex; gap: 10px; align-items: center; }
.room-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 12px; background: var(--lilac); color: var(--purple); }
.sidebar-heading h2 { margin: 0 0 4px; font: 700 13px "Manrope", sans-serif; }
.sidebar-heading p { margin: 0; color: var(--muted); font-size: 9px; }
.room-pill { display: flex; align-items: center; gap: 8px; margin: 27px 0 13px; padding: 11px 10px; border-radius: 9px; background: #f0edfa; color: #6752a8; font-size: 9px; font-weight: 700; letter-spacing: .8px; }
.room-pill .online-dot { width: 6px; height: 6px; }
.sidebar-message { position: relative; padding: 15px 12px; border: 1px solid #f3eadf; border-radius: 11px; background: #fffaf4; }
.sidebar-message .sparkle { position: absolute; top: 11px; right: 12px; color: #e9a365; }
.sidebar-message h3 { margin: 0 0 6px; font-size: 11px; }
.sidebar-message p, .safety-box p { margin: 0; color: #8e8798; font-size: 10px; line-height: 1.6; }
.safety-box { margin-top: auto; padding: 13px 12px; border-radius: 10px; background: #f5f3fa; }
.safety-box strong { font-size: 10px; }
.safety-box p { margin-top: 5px; font-size: 9px; }
.safety-box a { display: inline-block; margin-top: 11px; color: #6752a8; font-size: 9px; font-weight: 700; text-decoration: none; }
.leave-button { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding: 9px 2px; border: 0; background: none; color: #8d879a; font-size: 10px; text-align: left; cursor: pointer; }
.conversation { display: flex; min-width: 0; flex-direction: column; padding: 23px 28px 16px; }
.conversation-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.conversation-header h1 { margin: 0 0 4px; font: 800 18px "Manrope", sans-serif; letter-spacing: -.5px; }
.header-sparkle { color: #e5a56e; font-size: 14px; }
.conversation-header p { margin: 0; color: var(--muted); font-size: 10px; }
.your-alias { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; }
.alias-avatar { display: grid; width: 27px; height: 27px; place-items: center; border-radius: 9px; background: var(--lilac); color: var(--purple); font-size: 14px; }
.your-alias small, .your-alias strong { display: block; }
.your-alias small { margin-bottom: 3px; color: #a09aab; font-size: 7px; letter-spacing: .6px; }
.your-alias strong { font-size: 9px; }
.notice { display: flex; gap: 9px; align-items: flex-start; margin: 20px 0 17px; padding: 10px 12px; border-radius: 9px; background: #f5f2ff; color: #887bb0; }
.notice > span { padding-top: 1px; color: var(--purple); }
.notice p { margin: 0; font-size: 9px; line-height: 1.55; }
.notice strong { color: #62518e; }
.match-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; }
.match-controls p { flex: 1 1 100%; margin: 0; color: #827c91; font-size: 10px; }
.match-button { min-height: 36px; padding: 0 13px; border: 0; border-radius: 8px; background: var(--purple); color: white; font-size: 10px; font-weight: 700; cursor: pointer; }
.match-button:hover { background: var(--purple-dark); }
.secondary-match-button { border: 1px solid #e9e6ef; background: white; color: #625b70; }
.secondary-match-button:hover { background: #f7f5fb; color: #625b70; }
.match-button:disabled { cursor: wait; opacity: .6; }
.message-list { display: flex; flex: 1; flex-direction: column; gap: 15px; min-height: 320px; max-height: 430px; margin: 0; padding: 4px 5px 16px 0; overflow-y: auto; list-style: none; }
.message { position: relative; align-self: flex-start; max-width: 88%; }
.message.mine { align-self: flex-end; }
.message-topline { display: flex; align-items: center; gap: 7px; margin: 0 0 5px 3px; }
.message.mine .message-topline { justify-content: flex-end; }
.message-alias { color: #6855a3; font-size: 9px; font-weight: 700; }
.message-time { color: #aaa5b3; font-size: 8px; }
.message-bubble { padding: 10px 12px; border: 1px solid #f0edf4; border-radius: 4px 13px 13px; background: #faf9fc; color: #484255; font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; white-space: pre-wrap; }
.message.mine .message-bubble { border-color: #e8e0fb; border-radius: 13px 4px 13px 13px; background: #f0ecfb; }
.message-actions { display: flex; gap: 9px; margin: 5px 3px 0; opacity: .7; }
.message.mine .message-actions { justify-content: flex-end; }
.message-actions button { padding: 0; border: 0; background: none; color: #918a9c; font-size: 8px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.message-actions button:hover { color: #b94555; }
.empty-state { align-self: center; margin: auto; color: #a09aab; font-size: 11px; }
.composer { position: relative; display: flex; gap: 8px; align-items: center; margin-top: 5px; }
.composer input { flex: 1; min-width: 0; height: 44px; padding: 0 58px 0 13px; border: 1px solid #e9e6ef; border-radius: 10px; outline: 0; background: #fdfcff; font-size: 11px; }
.character-count { position: absolute; right: 87px; color: #aaa5b3; font-size: 8px; pointer-events: none; }
.composer button { display: flex; height: 42px; align-items: center; gap: 8px; padding: 0 14px; border: 0; border-radius: 9px; background: var(--purple); color: white; font-size: 10px; font-weight: 700; cursor: pointer; }
.composer button span { font-size: 15px; }
.chat-status { min-height: 12px; margin: 8px 0 0; color: #a09aab; font-size: 8px; text-align: center; }
.history-panel { margin-top: 8px; border-top: 1px solid var(--line); color: #746d84; font-size: 9px; }
.history-panel summary { padding: 9px 0 3px; cursor: pointer; font-weight: 700; }
.history-list { display: grid; gap: 8px; max-height: 180px; margin: 7px 0 0; padding: 0 4px 8px 0; overflow-y: auto; list-style: none; }
.history-item { padding: 9px 10px; border-radius: 8px; background: #faf9fc; }
.history-item header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; color: #8e8798; }
.history-item ol { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.history-item li { color: #625b70; line-height: 1.5; overflow-wrap: anywhere; }
.history-item li strong { color: #6752a8; }
.toast { position: fixed; right: 22px; bottom: 20px; z-index: 5; max-width: calc(100vw - 44px); padding: 12px 16px; transform: translateY(20px); border-radius: 10px; background: #302943; box-shadow: 0 9px 25px rgba(30, 20, 54, .2); color: white; font-size: 11px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.visible { transform: translateY(0); opacity: 1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; clip-path: inset(50%); }

@media (max-width: 850px) {
  .shell { padding: 0 24px; }
  .join-layout { grid-template-columns: 1fr 360px; gap: 35px; }
  .welcome h1 { font-size: 48px; }
  .chat-layout { grid-template-columns: 205px 1fr; }
  .conversation { padding-right: 19px; padding-left: 19px; }
}

@media (max-width: 650px) {
  .shell { padding: 0 17px; }
  .topbar { height: 72px; }
  .topbar-note { font-size: 10px; }
  .join-layout { display: flex; min-height: 0; flex-direction: column; align-items: stretch; gap: 21px; padding: 39px 0 34px; }
  .welcome h1 { margin-top: 17px; font-size: 43px; }
  .welcome-copy { font-size: 13px; }
  .welcome-art { display: none; }
  .small-note { margin: 13px 0 0; }
  .join-card { padding: 23px 22px 18px; }
  .page-footer { gap: 10px; font-size: 8px; }
  .chat-layout { display: flex; min-height: calc(100vh - 112px); flex-direction: column; margin: 15px 0 22px; }
  .chat-sidebar { flex-direction: row; align-items: center; gap: 9px; padding: 12px 13px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-heading { flex: 1; }
  .room-pill { margin: 0; padding: 9px; font-size: 8px; white-space: nowrap; }
  .sidebar-message, .safety-box, .leave-button { display: none; }
  .conversation { flex: 1; min-height: 0; padding: 17px 13px 12px; }
  .conversation-header { align-items: flex-start; }
  .conversation-header h1 { font-size: 16px; }
  .conversation-header p { max-width: 160px; font-size: 9px; line-height: 1.5; }
  .your-alias { gap: 5px; padding: 6px; }
  .your-alias small { font-size: 6px; }
  .your-alias strong { max-width: 74px; overflow: hidden; font-size: 8px; text-overflow: ellipsis; }
  .alias-avatar { width: 24px; height: 24px; }
  .notice { margin: 15px 0 12px; }
  .message-list { min-height: 260px; max-height: none; }
  .composer { gap: 6px; }
  .composer button { gap: 4px; padding: 0 10px; }
  .character-count { right: 77px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
