:root {
  --bg: #0a0a0c;
  --card: rgba(255, 255, 255, 0.05);
  --accent: #d4ff4f;
  --accent-ink: #0a0a0c;
  --text: #f5f5f7;
  --muted: rgba(255, 255, 255, 0.5);
  --muted-2: rgba(255, 255, 255, 0.32);
  --border: rgba(255, 255, 255, 0.1);
  --border-soft: rgba(255, 255, 255, 0.07);
  --danger: #ff6b6b;
  --warning: #ffb86c;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  --font-display: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
}

body {
  min-height: 100svh;
  overflow-x: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #191a22 0%, #0a0a0c 62%);
}

button, input, textarea { font: inherit; }

button { cursor: pointer; }

.app-shell {
  position: relative;
  min-height: 100svh;
  width: 100%;
}

.screen {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.glass-card {
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
}

.welcome-card {
  width: min(100%, 392px);
  padding: 38px 34px;
  border-radius: 28px;
  animation: rise-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.brand-mark,
.mini-logo {
  display: block;
  border-radius: 14px;
  object-fit: cover;
}

.brand-mark {
  width: 108px;
  height: 108px;
  margin: 0 auto 24px;
  border-radius: 26px;
}

.eyebrow {
  display: block;
  margin-top: 10px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.02;
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 14px 0 24px;
}

.name-form { text-align: left; }

.input-wrap { position: relative; }

.name-form input {
  width: 100%;
  height: 52px;
  border: 1px solid var(--border);
  border-radius: 16px;
  outline: none;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 0 18px;
  font-size: 16px;
  transition: 0.2s ease;
}

.name-form input::placeholder,
.message-form textarea::placeholder {
  color: rgba(255, 255, 255, 0.32);
}

.name-form input:focus {
  border-color: rgba(212, 255, 79, 0.6);
  box-shadow: 0 0 0 4px rgba(212, 255, 79, 0.1);
}

.form-error {
  min-height: 18px;
  margin: 8px 0 5px;
  color: var(--danger);
  font-size: 12px;
}

.terms-consent {
  margin: 14px 0 0;
  color: var(--muted-2);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.terms-consent a {
  color: var(--muted);
}

.terms-consent a:hover {
  color: var(--accent);
}

.primary-button {
  margin-top: 12px;
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 16px;
  color: #000;
  background: #fff;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  transition: transform 0.12s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 35px rgba(255, 255, 255, 0.2);
}

.primary-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.hidden { display: none !important; }

.chat-screen {
  height: 100svh;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 26px;
  border-radius: 0;
  border-width: 0 0 1px;
  background: rgba(16, 16, 20, 0.62);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-brand-button {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  transition: opacity 0.15s ease;
}

.header-brand-button:hover {
  opacity: 0.8;
}

.header-brand-text {
  display: flex;
  flex-direction: column;
}

.mini-logo {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
}

.header-brand h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.header-brand p {
  margin: 0;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 180px;
  margin-right: 4px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.header-user .avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #fff;
  color: #000;
  font-size: 12px;
  font-weight: 700;
}

.header-user span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-pill,
.online-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 8px currentColor;
}

.connection-pill[data-state="connecting"] .status-dot {
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.connection-pill[data-state="connected"] {
  color: rgba(255, 255, 255, 0.72);
}

.connection-pill[data-state="connected"] .status-dot {
  background: var(--accent);
}

.connection-pill[data-state="disconnected"] {
  color: var(--danger);
}

.connection-pill[data-state="disconnected"] .status-dot {
  background: rgba(255, 255, 255, 0.25);
}

.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-soft);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transition: 0.2s ease;
}

.icon-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.chat-layout {
  min-height: 0;
  flex: 1;
  display: flex;
  overflow: hidden;
}

.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 104px;
}

.message-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 28px;
  scroll-behavior: smooth;
}

.message-list::-webkit-scrollbar { width: 7px; }
.message-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.09);
  border-radius: 99px;
}

.empty-state {
  min-height: 100%;
  display: grid;
  place-content: center;
  text-align: center;
}

.empty-state p {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.message-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 14px;
  max-width: 100%;
  animation: message-in 0.25s ease both;
}

.message-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-soft);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.message-bubble {
  max-width: min(72%, 560px);
  padding: 11px 15px;
  border: 1px solid var(--border-soft);
  border-radius: 18px 18px 18px 6px;
  background: rgba(255, 255, 255, 0.07);
  overflow-wrap: anywhere;
}

.message-name-row {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.message-row.is-own-message .message-name-row {
  justify-content: flex-end;
}

.message-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}

.message-report-button {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-left: auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted-2);
  opacity: 0.5;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.message-report-button:hover {
  opacity: 1;
  color: var(--danger);
}

.message-report-button[data-reported="true"] {
  opacity: 1;
  color: var(--danger);
  cursor: default;
}

.message-report-button:disabled {
  cursor: default;
}

.message-time {
  display: block;
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.26);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.message-row.is-own-message {
  flex-direction: row-reverse;
}

.message-row.is-own-message .message-avatar {
  background: #fff;
  color: #000;
  border-color: transparent;
}

.message-row.is-own-message .message-bubble {
  border: 1px solid transparent;
  border-radius: 18px 18px 6px 18px;
  background: var(--accent);
}

.message-row.is-own-message .message-name {
  color: rgba(10, 10, 12, 0.6);
}

.message-row.is-own-message .message-text {
  color: var(--accent-ink);
}

.message-row.is-own-message .message-name,
.message-row.is-own-message .message-time {
  text-align: right;
}

.message-row.is-own-message .message-time {
  color: rgba(10, 10, 12, 0.45);
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: rgba(255, 255, 255, 0.92);
  font-size: 15px;
  line-height: 1.45;
}

.composer-wrap {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  padding: 18px 28px 20px;
  background: rgba(16, 16, 20, 0.62);
  border-top: 1px solid var(--border-soft);
}

.message-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.attach-button {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  color: #fff;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.message-form textarea {
  flex: 1;
  min-height: 46px;
  max-height: 45vh;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 18px;
  outline: none;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 13px 18px;
  font-size: 15px;
  line-height: 1.3;
  overflow-y: auto;
  transition: border-color 0.2s ease;
}

.message-form textarea:focus {
  border-color: rgba(212, 255, 79, 0.6);
}

.message-form textarea::-webkit-scrollbar { width: 7px; }
.message-form textarea::-webkit-scrollbar-track { background: transparent; }
.message-form textarea::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
}

.send-button {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border: 0;
  border-radius: 15px;
  background: #fff;
  color: #000;
  font-size: 19px;
  font-weight: 700;
  transition: transform 0.12s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.16s ease;
}

.send-button:hover {
  transform: translateY(-2px);
}

.send-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.composer-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 2px 0;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.composer-hint {
  white-space: nowrap;
}

.attachment-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
}

.attachment-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.attachment-size {
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 10px;
  flex-shrink: 0;
}

.remove-attachment {
  margin-left: auto;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}

.remove-attachment:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.16);
}

.message-file-image-link {
  display: inline-block;
  margin-top: 8px;
}

.message-file-image {
  display: block;
  max-width: 220px;
  max-height: 220px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
}

.message-file-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  max-width: 100%;
}

.message-file-icon {
  flex-shrink: 0;
  display: flex;
}

.message-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-row.is-own-message .message-file-link {
  background: rgba(10, 10, 12, 0.12);
  border-color: rgba(10, 10, 12, 0.18);
}

kbd {
  padding: 1px 4px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-bottom-color: rgba(255, 255, 255, 0.24);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.55);
  font-family: inherit;
  font-size: 8px;
}

.toast-container {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  width: min(360px, calc(100vw - 36px));
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(20, 20, 24, 0.92);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12px;
  backdrop-filter: blur(18px);
  animation: toast-in 0.25s ease both;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes message-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Legal page */
.legal-page {
  min-height: 100svh;
  padding: 28px 20px 64px;
}

.legal-shell {
  width: min(100%, 900px);
  margin: 0 auto;
}

.legal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.legal-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
}

.legal-brand .mini-logo {
  width: 30px;
  height: 30px;
  border-radius: 10px;
}

.legal-back {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.legal-back:hover { color: var(--accent); }

.legal-card {
  padding: clamp(26px, 5vw, 58px);
  border-radius: 26px;
}

.legal-kicker {
  margin-bottom: 12px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.legal-card h1 {
  margin-bottom: 14px;
  font-size: clamp(32px, 6vw, 52px);
}

.legal-intro,
.legal-card p,
.legal-card li {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.legal-intro {
  max-width: 720px;
  margin-bottom: 28px;
}

.legal-warning {
  margin: 26px 0 38px;
  padding: 18px 20px;
  border: 1px solid rgba(255, 184, 108, 0.32);
  border-radius: 16px;
  background: rgba(255, 184, 108, 0.08);
  color: rgba(255, 221, 184, 0.86);
}

.legal-card h2 {
  margin: 36px 0 10px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.25;
}

.legal-card h2:first-of-type { margin-top: 0; }

.legal-card ul,
.legal-card ol {
  margin: 10px 0 18px;
  padding-left: 24px;
}

.legal-card li { margin: 6px 0; }

.legal-card strong { color: rgba(255, 255, 255, 0.82); }

.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 12px;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
}

.legal-contact {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--border-soft);
}

.legal-bottom-link {
  display: inline-block;
  margin-top: 22px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.legal-bottom-link:hover { color: var(--text); }

@media (min-width: 760px) {
  .message-list { padding: 32px; }
}

@media (max-width: 760px) {
  .header-user { max-width: 140px; }
}

@media (max-width: 620px) {
  .screen { padding: 16px; }
  .welcome-card { padding: 30px 22px; border-radius: 24px; }
  .chat-header { padding: 12px 16px; }
  .header-brand p { display: none; }
  .online-pill span:last-child { display: none; }
  .connection-pill span:last-child { display: none; }
  .connection-pill { padding: 0 10px; }
  .message-list { padding: 18px; }
  .message-bubble { max-width: calc(100vw - 90px); }
  .chat-main { padding-bottom: 92px; }
  .composer-wrap { padding: 12px 14px 16px; }
  .composer-footer span:first-child { font-size: 8px; }
  .legal-page { padding: 18px 14px 40px; }
  .legal-nav { margin-bottom: 18px; }
  .legal-card { border-radius: 20px; }
  .legal-card p,
  .legal-card li { font-size: 13px; }
}

@media (max-width: 420px) {
  .welcome-card { padding: 26px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
