:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-strong: #1a1a1a;
  --border: rgba(255, 255, 255, 0.06);
  --text: #f3f4f6;
  --text-dim: #8b8b8b;
  --text-muted: #666666;
  --accent: #00d4ff;
  --accent-ink: #000000;
  --ai-bg: #0d1f2d;
  --danger: #ff7a7a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 28px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --keyboard-offset: 0px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(0, 212, 255, 0.08), transparent 28%),
    radial-gradient(circle at bottom, rgba(255, 255, 255, 0.03), transparent 32%),
    var(--bg);
  color: var(--text);
}

html,
body {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 4px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
  background: transparent;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

body {
  min-height: 100vh;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  background: transparent;
  color: inherit;
}

.shell {
  min-height: 100vh;
}

.home-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: calc(32px + var(--safe-top)) 20px calc(32px + var(--safe-bottom));
}

.home-card {
  width: min(100%, 460px);
  background: linear-gradient(180deg, rgba(18, 18, 18, 0.96), rgba(14, 14, 14, 0.94));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.brand {
  text-align: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: inline-block;
  font-size: 0.92rem;
  letter-spacing: 0.24em;
  color: rgba(255, 255, 255, 0.76);
  font-variant-caps: all-small-caps;
}

.brand-tagline {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.stack {
  display: grid;
  gap: 14px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field,
.composer-input,
select {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  color: #f3f4f6;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  padding: 15px 16px;
  outline: none;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.field:focus,
.composer-input:focus,
select:focus {
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: none;
  background: rgba(255, 255, 255, 0.04);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus {
  -webkit-text-fill-color: #f3f4f6;
  -webkit-box-shadow: 0 0 0 1000px rgba(255, 255, 255, 0.04) inset;
  transition: background-color 9999s ease-in-out 0s;
}

.actions {
  display: grid;
  gap: 12px;
  margin-top: 6px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.pill-btn,
.send-btn,
.save-room-btn,
.room-status-chip,
.burn-btn {
  border-radius: 18px;
  padding: 15px 18px;
  font-weight: 600;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.secondary-btn:hover,
.ghost-btn:hover,
.pill-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled,
.secondary-btn:disabled,
.ghost-btn:disabled,
.pill-btn:disabled,
.send-btn:disabled,
.save-room-btn:disabled,
.modal-confirm:disabled {
  opacity: 0.65;
  cursor: default;
  transform: none;
}

.secondary-btn,
.ghost-btn {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.secondary-btn:hover,
.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
  color: #000000;
  font-weight: 700;
  border: none;
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 0 24px rgba(0, 212, 255, 0.25), 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 32px rgba(0, 212, 255, 0.4), 0 8px 24px rgba(0, 0, 0, 0.5);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow: 0 0 16px rgba(0, 212, 255, 0.2);
}

.home-note,
.join-note {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.45;
}

.rejoin-strip {
  margin-top: 18px;
}

.rejoin-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.rejoin-copy {
  min-width: 0;
}

.rejoin-title {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.rejoin-room {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 700;
}

.toast {
  margin-top: 16px;
  min-height: 22px;
  color: var(--danger);
  font-size: 0.92rem;
}

.room-shell {
  min-height: 100vh;
  padding-top: calc(112px + var(--safe-top));
  padding-bottom: calc(108px + var(--safe-bottom));
}

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: calc(12px + var(--safe-top)) 16px 10px;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.room-code-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.room-code-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.room-code-btn {
  background: transparent;
  color: var(--text);
  border: 0;
  padding: 0;
  text-align: left;
  min-width: 0;
}

.room-code-label {
  display: block;
  color: var(--text-dim);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.room-code-value {
  display: block;
  margin-top: 4px;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.participant-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.participant-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.participant-dot.is-on {
  background: rgba(255, 255, 255, 0.85);
}

.participant-count {
  margin-left: 4px;
  color: var(--text-dim);
  font-size: 0.86rem;
}

.ai-btn {
  padding: 11px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-btn.is-active {
  background: rgba(0, 212, 255, 0.1);
  color: #00d4ff;
  border-color: rgba(0, 212, 255, 0.24);
}

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

.share-room-btn {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  white-space: nowrap;
}

.burn-btn {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 80, 80, 0.08);
  color: #ff8e8e;
  border: 1px solid rgba(255, 80, 80, 0.16);
  line-height: 1;
  font-size: 1rem;
}

.mode-toggle {
  display: flex;
  gap: 8px;
}

.mode-option {
  flex: 1;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 500;
}

.mode-option.is-active {
  background: rgba(0, 212, 255, 0.12);
  color: #00d4ff;
  border-color: rgba(0, 212, 255, 0.3);
}

.identity-chip {
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.identity-chip.is-locked {
  opacity: 0.5;
  cursor: default;
}

.typing-indicator {
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 0 4px 6px;
  min-height: 20px;
}

.meta-stack {
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

.privacy-note {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.3);
  line-height: 1.6;
  display: grid;
  gap: 4px;
}

.privacy-line {
  margin: 0;
}

.conversion-strip {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(0, 212, 255, 0.06);
  border: 1px solid rgba(0, 212, 255, 0.12);
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.5;
}

.conversion-strip a {
  color: #00d4ff;
  text-decoration: none;
  font-weight: 500;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: #111111;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 28px 24px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.modal-body {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-cancel {
  flex: 1;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-confirm {
  flex: 1;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 80, 80, 0.15);
  color: #ff6b6b;
  border: 1px solid rgba(255, 80, 80, 0.3);
}

.modal-confirm:disabled {
  opacity: 0.3;
  cursor: default;
}

.invite-header {
  text-align: center;
  margin-bottom: 20px;
}

.invite-eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.invite-code {
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.thread {
  padding: 18px 14px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.thread-disclaimer {
  text-align: center;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.18);
  padding: 12px 20px 8px;
  line-height: 1.5;
  user-select: none;
}

.thread::-webkit-scrollbar {
  width: 4px;
}

.thread::-webkit-scrollbar-track {
  background: transparent;
}

.thread::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

.thread::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

.share-card {
  margin: 0 auto 18px;
  max-width: 720px;
  background: rgba(17, 17, 17, 0.88);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px;
  animation: rise-in 0.24s ease;
}

.share-code {
  font-size: clamp(1.55rem, 5vw, 2.25rem);
  font-weight: 800;
  letter-spacing: 0.12em;
}

.share-hint {
  margin-top: 10px;
  color: var(--text-dim);
  line-height: 1.5;
}

.message-list {
  max-width: 820px;
  margin: 0 auto;
}

.cluster {
  margin-bottom: 14px;
}

.cluster-meta {
  margin: 0 0 6px;
  color: var(--text-dim);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
}

.cluster.is-outgoing .cluster-meta {
  text-align: right;
}

.bubble-stack {
  display: grid;
  gap: 4px;
}

.bubble-row {
  display: flex;
}

.bubble-row.is-outgoing {
  justify-content: flex-end;
}

.bubble {
  max-width: min(76vw, 440px);
  padding: 12px 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid transparent;
}

.bubble.is-outgoing {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 18px 18px 4px 18px;
}

.bubble.is-incoming {
  background: var(--surface-strong);
  color: var(--text);
  border-radius: 18px 18px 18px 4px;
}

.bubble.is-ai {
  background: var(--ai-bg);
  color: var(--accent);
  border-left: 2px solid var(--accent);
  border-radius: 18px 18px 18px 4px;
}

.cluster-time {
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.34);
  font-size: 0.74rem;
}

.cluster.is-outgoing .cluster-time {
  text-align: right;
}

.empty-state {
  max-width: 520px;
  margin: 56px auto 0;
  text-align: center;
  color: var(--text-dim);
  line-height: 1.6;
}

.new-indicator {
  position: fixed;
  left: 50%;
  bottom: calc(118px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 25;
}

.pill-btn {
  background: rgba(15, 15, 15, 0.9);
  color: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.composer-wrap {
  position: fixed;
  inset: auto 0 0;
  z-index: 20;
  padding: 12px 14px calc(12px + var(--safe-bottom) + var(--keyboard-offset));
  background: linear-gradient(180deg, rgba(10, 10, 10, 0), rgba(10, 10, 10, 0.95) 24%);
}

.upgrade-banner {
  max-width: 820px;
  margin: 0 auto 10px;
  padding: 0 4px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 0.84rem;
}

.upgrade-banner a {
  color: rgba(255, 255, 255, 0.76);
  text-decoration-color: rgba(0, 212, 255, 0.28);
}

.composer {
  max-width: 820px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  background: rgba(17, 17, 17, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 22px;
  padding: 10px;
  box-shadow: var(--shadow);
}

.composer-input {
  min-height: 50px;
  max-height: 140px;
  resize: none;
  overflow: hidden;
  scrollbar-width: none;
}

.composer-input::-webkit-scrollbar {
  display: none;
}

.send-btn {
  min-width: 78px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #111111;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 700;
}

.save-room-btn {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  white-space: nowrap;
}

.room-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 212, 255, 0.08);
  color: #00d4ff;
  border: 1px solid rgba(0, 212, 255, 0.18);
  font-size: 0.78rem;
  white-space: nowrap;
}

.copy-toast {
  color: var(--accent);
}

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

@media (min-width: 720px) {
  .home-card {
    padding: 30px;
  }

  .thread {
    padding-left: 24px;
    padding-right: 24px;
  }

  .composer-wrap {
    padding-left: 24px;
    padding-right: 24px;
  }
}
