:root {
  color-scheme: dark;
  --bg: #070613;
  --panel: rgba(18, 18, 30, 0.62);
  --panel-strong: rgba(28, 27, 43, 0.78);
  --line: rgba(255, 255, 255, 0.13);
  --text: #f6f1ea;
  --muted: rgba(246, 241, 234, 0.62);
  --accent: #f6f2ff;
  --accent-2: #b995ff;
  --danger: #ff7a7a;
  --shadow: rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  background-color: #070613;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background-color: #070613;
  background:
    radial-gradient(ellipse at 52% 38%, rgba(83, 72, 160, 0.2), transparent 34%),
    radial-gradient(ellipse at 75% 58%, rgba(92, 40, 88, 0.1), transparent 34%),
    radial-gradient(ellipse at 18% 22%, rgba(28, 39, 102, 0.4), transparent 40%),
    linear-gradient(135deg, #050617 0%, #0a0a2a 50%, #180916 100%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell,
.stage-panel {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: #070613;
}

.stage-panel::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.44), transparent 24%, transparent 74%, rgba(0, 0, 0, 0.5)),
    radial-gradient(ellipse at 50% 38%, rgba(255, 236, 220, 0.045), transparent 24%),
    radial-gradient(ellipse at 50% 78%, rgba(114, 91, 205, 0.05), transparent 36%);
  z-index: 1;
}

.stage-panel::after {
  position: absolute;
  top: 45%;
  left: 50%;
  z-index: 1;
  width: min(46vw, 620px);
  height: min(76vh, 780px);
  content: "";
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 34%, rgba(255, 228, 205, 0.12), transparent 29%),
    radial-gradient(ellipse at 48% 48%, rgba(108, 86, 190, 0.11), transparent 54%);
  filter: blur(34px);
  opacity: 0.7;
  transform: translate(-50%, -50%);
}

.avatar-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#vrmCanvas {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  background-color: #070613;
  cursor: default;
}

#vrmCanvas:active {
  cursor: default;
}

.load-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 28px;
  pointer-events: none;
  color: var(--muted);
  text-align: center;
  background: rgba(7, 6, 19, 0.72);
}

.load-overlay strong {
  color: var(--text);
  font-size: 18px;
}

.load-overlay.is-slow {
  inset: auto 50% 132px auto;
  width: min(520px, calc(100vw - 32px));
  min-height: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 14px 18px;
  place-content: center;
  background: rgba(16, 14, 28, 0.82);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px);
  transform: translateX(50%);
}

.load-overlay.is-slow strong {
  font-size: 15px;
}

.load-overlay.is-slow span {
  font-size: 13px;
}

.load-overlay.hidden,
.hidden {
  display: none !important;
}

.brand-logo {
  position: fixed;
  top: 22px;
  left: 28px;
  z-index: 12;
  width: 142px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.28));
}

.auth-button {
  position: fixed;
  top: 22px;
  right: 26px;
  z-index: 12;
  min-width: 72px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
  cursor: pointer;
}

.auth-button.is-logged-in {
  border-color: rgba(185, 149, 255, 0.38);
  background: rgba(185, 149, 255, 0.16);
}

.auth-button.auth-pending {
  pointer-events: none;
  opacity: 0.68;
}

.account-menu {
  position: fixed;
  top: 70px;
  right: 26px;
  z-index: 18;
  min-width: 150px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 6px;
  background: rgba(15, 13, 25, 0.86);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(20px);
}

.account-menu-item {
  width: 100%;
  height: 38px;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
}

.account-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.account-menu-item.danger {
  color: #ffaaa6;
}

.user-pill {
  display: block;
  max-width: 150px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-tools {
  position: fixed;
  top: 96px;
  right: 28px;
  z-index: 12;
  display: grid;
  gap: 14px;
}

.tool-button,
.icon-button,
.mic-button,
.send-button,
.chip {
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.tool-button,
.icon-button,
.mic-button,
.history-toggle {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.tool-button svg,
.icon-button svg,
.mic-button svg,
.history-toggle svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-button:hover,
.icon-button:hover,
.mic-button:hover,
.history-toggle:hover,
.send-button:hover {
  border-color: rgba(185, 149, 255, 0.72);
  background: rgba(185, 149, 255, 0.2);
}

.history-toggle {
  position: fixed;
  top: 82px;
  left: 18px;
  z-index: 18;
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  backdrop-filter: blur(18px);
}

.conversation-backdrop {
  position: fixed;
  inset: 0;
  z-index: 17;
  background: rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(2px);
}

.chat-panel {
  position: fixed;
  top: 104px;
  right: 94px;
  z-index: 10;
  display: flex;
  width: min(430px, calc(100vw - 128px));
  height: min(58vh, 560px);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(12, 12, 22, 0.46);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(22px);
  transition: opacity 160ms ease, transform 160ms ease, pointer-events 160ms ease;
}

.chat-panel.collapsed {
  opacity: 0;
  pointer-events: none;
  transform: translateX(18px) scale(0.98);
}

.conversation-panel {
  position: fixed;
  top: 104px;
  left: 28px;
  z-index: 10;
  width: min(240px, calc(100vw - 56px));
  max-height: 346px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 10px;
  background: rgba(12, 12, 22, 0.42);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(20px);
}

.conversation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px 8px;
  color: rgba(246, 241, 234, 0.74);
  font-size: 12px;
  font-weight: 700;
}

.conversation-new {
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.conversation-list {
  max-height: 288px;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 2px;
}

.conversation-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  color: rgba(246, 241, 234, 0.78);
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
  text-align: left;
}

.conversation-content {
  min-width: 0;
}

.conversation-delete {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: rgba(246, 241, 234, 0.54);
  font-size: 20px;
}

.conversation-delete:hover {
  color: #ffaaa6;
  background: rgba(255, 122, 122, 0.14);
}

.conversation-item + .conversation-item {
  margin-top: 6px;
}

.conversation-item:hover,
.conversation-item.active {
  border-color: rgba(185, 149, 255, 0.45);
  background: rgba(185, 149, 255, 0.15);
}

.conversation-title {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-meta {
  display: block;
  margin-top: 2px;
  color: rgba(246, 241, 234, 0.42);
  font-size: 11px;
}

.conversation-empty {
  padding: 10px;
  color: rgba(246, 241, 234, 0.42);
  font-size: 12px;
}

.messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.message {
  width: min(100%, 390px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

.message.user {
  align-self: flex-end;
  background: rgba(117, 92, 164, 0.28);
}

.message.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
}

.message .speaker {
  display: block;
  margin-bottom: 4px;
  color: #f4c86a;
  font-size: 12px;
  font-weight: 700;
}

.message-text {
  display: inline;
}

.ticker-link-wrap {
  position: relative;
  display: inline-block;
  white-space: normal;
}

.ticker-link {
  border-radius: 6px;
  padding: 0 4px;
  color: #f7d875;
  font-weight: 800;
  text-decoration: none;
  background: rgba(247, 216, 117, 0.12);
  box-shadow: inset 0 0 0 1px rgba(247, 216, 117, 0.24);
}

.ticker-link:hover,
.ticker-link:focus-visible {
  color: #fff2a6;
  background: rgba(247, 216, 117, 0.2);
  outline: none;
}

.ticker-trade-popover {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  display: none;
  width: 174px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 9px;
  color: var(--text);
  white-space: normal;
  background: rgba(18, 17, 30, 0.68);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px) saturate(1.2);
  pointer-events: auto;
}

.ticker-trade-popover::after {
  position: absolute;
  inset: -10px;
  z-index: -1;
  content: "";
}

.ticker-link-wrap.is-open .ticker-trade-popover,
.ticker-trade-popover.is-open,
.ticker-link-wrap:hover .ticker-trade-popover,
.ticker-link-wrap:focus-within .ticker-trade-popover {
  display: grid;
  gap: 6px;
}

.ticker-trade-popover strong {
  padding: 0 2px;
  font-size: 11px;
  color: rgba(246, 241, 234, 0.76);
}

.trade-venue-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border-radius: 8px;
  padding: 5px 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.trade-venue-row:hover,
.trade-venue-row:focus-visible {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.trade-venue-logo {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: contain;
  background: transparent;
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  white-space: normal;
}

.message-attachment {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(185, 149, 255, 0.32);
  border-radius: 999px;
  padding: 4px 9px;
  color: rgba(246, 241, 234, 0.86);
  text-decoration: none;
  background: rgba(185, 149, 255, 0.12);
}

.message-attachment img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
}

.message-attachment span {
  overflow: hidden;
  max-width: 210px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message.thinking::after {
  display: inline-block;
  margin-top: 2px;
  color: rgba(246, 241, 234, 0.72);
  content: "Thinking";
  font-size: 14px;
  animation: thinkingPulse 1.1s ease-in-out infinite;
}

@keyframes thinkingPulse {
  0% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.35;
  }
}

.legal-links {
  position: fixed;
  right: 26px;
  bottom: 18px;
  z-index: 12;
  display: flex;
  gap: 14px;
  font-size: 12px;
}

.legal-links a {
  color: rgba(246, 241, 234, 0.62);
  text-decoration: none;
}

.legal-links a:hover {
  color: var(--text);
}

body.legal-page {
  min-height: 100%;
  overflow: auto;
}

.legal-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 64px;
}

.legal-brand {
  display: inline-flex;
  align-items: center;
  margin-bottom: 28px;
}

.legal-brand img {
  width: 152px;
  height: auto;
}

.legal-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: clamp(24px, 4vw, 48px);
  color: rgba(246, 241, 234, 0.84);
  background: rgba(18, 18, 30, 0.72);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
}

.legal-card h1,
.legal-card h2,
.legal-card h3 {
  color: var(--text);
}

.legal-card h1 {
  margin: 0 0 8px;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1;
}

.legal-card h2 {
  margin: 34px 0 12px;
  font-size: 20px;
}

.legal-card h3 {
  margin: 22px 0 8px;
  font-size: 16px;
}

.legal-card p,
.legal-card li {
  font-size: 15px;
  line-height: 1.72;
}

.legal-card ul {
  padding-left: 22px;
}

.legal-card a {
  color: #d9c6ff;
}

.legal-updated {
  margin: 0 0 28px;
  color: var(--muted);
}

@media (max-width: 860px) {
  .legal-links {
    right: 18px;
    bottom: 10px;
  }

  .legal-shell {
    padding: 28px 0 48px;
  }
}

.knowledge-debug {
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 8px;
  color: var(--muted);
  font-size: 11px;
  white-space: normal;
}

.knowledge-debug summary {
  cursor: pointer;
  color: rgba(185, 149, 255, 0.95);
  font-weight: 700;
}

.knowledge-source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
  padding-left: 0;
}

.knowledge-source-title {
  color: rgba(246, 241, 234, 0.82);
  font-weight: 600;
}

.knowledge-source-path {
  overflow-wrap: anywhere;
  color: var(--muted);
}

.knowledge-source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.knowledge-source-list a {
  border: 1px solid rgba(185, 149, 255, 0.38);
  border-radius: 999px;
  padding: 2px 7px;
  color: rgba(220, 202, 255, 0.95);
  text-decoration: none;
}

.composer {
  position: fixed;
  right: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 14;
  display: grid;
  grid-template-columns: 56px minmax(240px, 680px);
  gap: 10px;
  width: min(746px, calc(100vw - 40px));
  transform: translateX(50%);
}

.mic-button {
  width: 56px;
  height: 56px;
  background: rgba(55, 43, 104, 0.78);
}

.mic-button.recording {
  border-color: rgba(255, 122, 122, 0.7);
  color: var(--danger);
  background: rgba(255, 122, 122, 0.18);
}

#messageInput {
  min-width: 0;
  height: 56px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  outline: 0;
  padding: 0 22px;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(82, 66, 137, 0.82), rgba(130, 85, 112, 0.66)),
    rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
}

#messageInput::placeholder {
  color: rgba(246, 241, 234, 0.54);
}

#messageInput:focus {
  border-color: rgba(255, 255, 255, 0.34);
}

.send-button {
  height: 56px;
  border-radius: 999px;
  color: #15131f;
  background: rgba(255, 255, 255, 0.94);
  font-weight: 700;
}

.runtime-note {
  position: fixed;
  right: 50%;
  bottom: 4px;
  z-index: 14;
  width: min(720px, calc(100vw - 48px));
  margin: 0;
  color: rgba(246, 241, 234, 0.45);
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
  transform: translateX(50%);
}

.settings-dialog {
  width: min(520px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  color: var(--text);
  background: rgba(24, 24, 38, 0.96);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(5px);
}

.settings-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

.settings-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.settings-form input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  padding: 0 12px;
  color: var(--text);
  background: #10101c;
}

.settings-form input:focus {
  border-color: rgba(185, 149, 255, 0.72);
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.oauth-actions {
  display: grid;
  gap: 8px;
}

.oauth-actions.hidden {
  display: none;
}

.oauth-button {
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.075);
  cursor: pointer;
}

.oauth-button:hover {
  border-color: rgba(185, 149, 255, 0.62);
  background: rgba(185, 149, 255, 0.15);
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.chip {
  border-radius: 999px;
  padding: 10px 14px;
}

@media (max-width: 860px) {
  .history-toggle {
    display: grid;
  }

  body.chat-panel-open .history-toggle {
    display: none;
  }

  .chat-panel {
    top: 96px;
    right: 18px;
    left: 18px;
    z-index: 16;
    width: auto;
    height: min(50vh, 470px);
  }

  .side-tools {
    top: 100px;
    right: 18px;
    z-index: 26;
  }

  body.chat-panel-open .side-tools {
    z-index: 32;
  }

  body.chat-panel-open .messages {
    padding-top: 68px;
  }

  .conversation-panel {
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 18;
    width: min(320px, 84vw);
    max-height: none;
    border-radius: 0 18px 18px 0;
    padding: 88px 14px 18px;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .conversation-panel.drawer-open {
    transform: translateX(0);
  }

  .brand-logo {
    top: 18px;
    left: 18px;
    width: 118px;
  }

  .conversation-list {
    max-height: calc(100vh - 150px);
  }

  .composer {
    grid-template-columns: 52px minmax(0, 1fr);
    bottom: max(14px, env(safe-area-inset-bottom));
  }

  .mic-button,
  #messageInput,
  .send-button {
    height: 52px;
  }
}

.account-menu-item.upgrade { color: #ffd96b; font-weight: 700; }
.account-menu:has(.account-menu-item.upgrade) { min-width: 190px; }
.upgrade-dialog { width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: 1px solid rgba(255,255,255,.16); border-radius: 8px; padding: 0; overflow: auto; color: var(--text); background: rgba(10,10,17,.97); box-shadow: 0 28px 100px rgba(0,0,0,.62); }
.upgrade-dialog::backdrop { background: rgba(4,4,10,.72); backdrop-filter: blur(12px); }
.upgrade-shell { position: relative; padding: 34px; }
.upgrade-close { position: absolute; top: 16px; right: 16px; display: grid; width: 36px; height: 36px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; place-items: center; color: var(--muted); background: rgba(255,255,255,.06); cursor: pointer; }
.upgrade-close svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.upgrade-head { max-width: 620px; margin: 0 auto 28px; text-align: center; }
.plus-mark { display: inline-block; margin-bottom: 12px; border-radius: 999px; padding: 6px 12px; color: #090912; background: #ffd45d; font-size: 12px; font-weight: 800; }
.upgrade-head h2 { font-size: 28px; }
.upgrade-head p { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.upgrade-content { display: grid; grid-template-columns: minmax(0,.95fr) minmax(320px,1.05fr); gap: 24px; }
.feature-comparison { align-self: stretch; padding: 8px 4px; }
.feature-row { display: grid; grid-template-columns: minmax(0,1fr) 56px 64px; min-height: 42px; align-items: center; border-bottom: 1px solid rgba(255,255,255,.08); color: var(--muted); font-size: 13px; }
.feature-row > :nth-child(n+2) { text-align: center; }
.feature-row strong { color: #ffd96b; }
.feature-header { min-height: 34px; color: rgba(255,255,255,.45); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.upgrade-checkout { display: flex; flex-direction: column; }
.billing-options, .payment-actions { display: grid; gap: 10px; }
.billing-option { position: relative; display: grid; grid-template-columns: 1fr auto; min-height: 78px; align-items: center; border: 1px solid rgba(255,255,255,.16); border-radius: 8px; padding: 0 48px 0 18px; background: rgba(255,255,255,.045); cursor: pointer; }
.billing-option.selected { border-color: #ffd45d; background: rgba(255,212,93,.08); }
.billing-option input { position: absolute; opacity: 0; }
.billing-option span { display: grid; gap: 4px; }
.billing-option small { color: var(--muted); }
.billing-option strong { font-size: 21px; }
.billing-option del { margin-left: 7px; color: rgba(255,255,255,.36); font-size: 12px; }
.billing-option em { position: absolute; top: -9px; right: 12px; border-radius: 999px; padding: 3px 8px; color: #090912; background: #ffd45d; font-size: 11px; font-style: normal; font-weight: 800; }
.billing-option i { position: absolute; right: 18px; width: 17px; height: 17px; border: 1px solid rgba(255,255,255,.32); border-radius: 50%; }
.billing-option.selected i { border: 5px solid #ffd45d; }
.payment-actions { margin-top: 16px; gap: 9px; }
.payment-button { height: 46px; border: 0; border-radius: 8px; color: #090912; font-weight: 800; cursor: pointer; }
.payment-button.stripe { background: #f7f5ff; }
.payment-button.infini { border: 1px solid rgba(95,239,184,.4); color: #e9fbf4; background: rgba(30,156,112,.18); }
.payment-button:disabled { cursor: wait; opacity: .55; }
.upgrade-note { min-height: 18px; margin: 12px 0 0; color: rgba(255,255,255,.43); font-size: 11px; line-height: 1.5; text-align: center; }
@media (max-width: 860px) {
  .upgrade-shell { padding: 28px 18px 20px; }
  .upgrade-head h2 { font-size: 22px; }
  .upgrade-content { grid-template-columns: 1fr; gap: 18px; }
  .feature-row { min-height: 38px; }
}

.membership-entry {
  position: fixed;
  bottom: 18px;
  left: 28px;
  z-index: 13;
  display: inline-flex;
  height: 42px;
  align-items: center;
  gap: 9px;
  border: 0;
  padding: 0;
  color: rgba(246, 241, 234, 0.52);
  background: transparent;
  cursor: pointer;
}

.membership-entry-copy {
  font-size: 12px;
  font-weight: 650;
}

.membership-entry-badge {
  display: inline-flex;
  height: 32px;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 0 10px 0 7px;
  color: rgba(246, 241, 234, 0.62);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.membership-entry-badge svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.membership-entry-badge strong {
  font-size: 12px;
  letter-spacing: 0;
}

.membership-entry:hover .membership-entry-badge {
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--text);
  transform: translateY(-1px);
}

.membership-entry.is-plus {
  color: rgba(255, 235, 169, 0.84);
}

.membership-entry.is-plus .membership-entry-badge {
  border-color: #ff91c8;
  color: #17121c;
  background: #ffd65c;
  box-shadow: 0 10px 30px rgba(255, 170, 85, 0.22), inset 0 -2px 0 rgba(225, 128, 52, 0.24);
}

.membership-entry.is-plus .membership-entry-badge svg {
  fill: #ea4d9b;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.5));
}

.membership-status {
  margin-top: 18px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  padding: 15px 18px;
  text-align: left;
  background: rgba(255, 255, 255, 0.045);
}

.upgrade-head .membership-status-main {
  margin: 0;
  color: rgba(246, 241, 234, 0.88);
  font-size: 17px;
  font-weight: 750;
  line-height: 1.4;
}

.upgrade-head .membership-status-expiry {
  margin: 5px 0 0;
  color: rgba(246, 241, 234, 0.52);
  font-size: 12px;
  line-height: 1.5;
}

.upgrade-dialog.is-plus .membership-status {
  border-color: rgba(255, 214, 92, 0.58);
  background: rgba(255, 214, 92, 0.09);
  box-shadow: inset 4px 0 0 #ffd65c;
}

.upgrade-dialog.is-plus .membership-status-main {
  color: #ffe38a;
  font-size: 20px;
}

.upgrade-dialog.is-plus .membership-status-expiry {
  color: rgba(255, 240, 190, 0.72);
}

.upgrade-dialog.is-plus .upgrade-content {
  grid-template-columns: 1fr;
  width: min(620px, 100%);
  margin: 0 auto;
}

.upgrade-dialog.is-plus .upgrade-checkout {
  display: none;
}

.membership-cancel {
  margin: 10px 0 0;
  border: 0;
  padding: 0;
  color: rgba(255, 240, 190, 0.62);
  background: transparent;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.membership-cancel:hover { color: #fff0be; }
.membership-cancel:disabled { opacity: 0.5; cursor: wait; }
.membership-cancel.hidden { display: none; }

.membership-toast {
  position: fixed;
  top: 22px;
  left: 50%;
  z-index: 100;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 28px;
  width: min(420px, calc(100vw - 28px));
  align-items: center;
  gap: 11px;
  border: 1px solid rgba(255, 214, 92, 0.48);
  border-radius: 8px;
  padding: 12px 12px 12px 14px;
  color: var(--text);
  background: rgba(20, 18, 27, 0.96);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(20px);
  transform: translateX(-50%);
  animation: membershipToastIn 220ms ease-out;
}

.membership-toast.hidden {
  display: none;
}

.membership-toast-icon {
  display: grid;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  place-items: center;
  color: #17121c;
  background: #ffd65c;
}

.membership-toast-icon svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.membership-toast > div {
  display: grid;
  gap: 3px;
}

.membership-toast strong {
  font-size: 14px;
}

.membership-toast > div > span {
  color: rgba(246, 241, 234, 0.58);
  font-size: 12px;
}

.membership-toast button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  color: rgba(246, 241, 234, 0.56);
  background: transparent;
  font-size: 20px;
  cursor: pointer;
}

@keyframes membershipToastIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 860px) {
  .membership-entry {
    bottom: max(78px, calc(env(safe-area-inset-bottom) + 70px));
    left: 18px;
  }

  body.chat-panel-open .membership-entry {
    opacity: 0;
    pointer-events: none;
  }

  .upgrade-head .membership-status-main,
  .upgrade-dialog.is-plus .membership-status-main {
    font-size: 16px;
  }

  .membership-toast {
    top: max(12px, env(safe-area-inset-top));
  }
}

@media (prefers-reduced-motion: reduce) {
  .membership-toast { animation: none; }
  .membership-entry-badge { transition: none; }
}
