:root {
  --bg: #1a1030;
  --bg-elevated: #241a3d;
  --purple: #7c3aed;
  --purple-light: #a78bfa;
  --green: #34d399;
  --red: #f87171;
  --text: #f4f2fb;
  --text-dim: #b8b0d4;
  --border: rgba(255,255,255,0.08);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}

body {
  background: radial-gradient(circle at 20% 0%, #3b1f68 0%, var(--bg) 55%);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }

.screen { min-height: 100vh; display: flex; flex-direction: column; }

/* Onboarding */
#onboarding { align-items: center; justify-content: center; padding: 24px; }
.onboarding-card { width: 100%; max-width: 380px; text-align: center; }
.logo { font-size: 48px; margin-bottom: 4px; }
.onboarding-card h1 { margin: 0 0 4px; font-size: 28px; }
.tagline { color: var(--text-dim); margin: 0 0 24px; font-size: 14px; }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.field-label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin: 14px 0 6px;
}

input, textarea {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  resize: none;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--purple-light);
}
input::placeholder, textarea::placeholder { color: #7b7396; }

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  margin-top: 18px;
  cursor: pointer;
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: linear-gradient(135deg, var(--purple), #9333ea); color: white; }
.btn-secondary { background: rgba(255,255,255,0.08); color: var(--text); }
.btn-approve { background: linear-gradient(135deg, #10b981, var(--green)); color: #06281c; }
.btn-deny { background: linear-gradient(135deg, #ef4444, var(--red)); color: #3a0a0a; }

.respond-actions { display: flex; gap: 10px; margin-top: 18px; }
.respond-actions .btn { margin-top: 0; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 10px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; }
.brand-emoji { font-size: 22px; }
.icon-btn {
  background: rgba(255,255,255,0.08);
  border: none;
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 16px;
  color: var(--text);
  cursor: pointer;
}

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

.room-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 999px;
  padding: 8px 14px 8px 10px;
  color: var(--text);
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  max-width: 70%;
}
.room-pill #active-room-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-pill .chevron { color: var(--text-dim); font-size: 12px; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 14px;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.link-box {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--purple-light);
  word-break: break-all;
  margin: 14px 0;
}

.rooms-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  font-weight: 700;
}
.room-row.active { border-color: var(--purple-light); background: rgba(124,58,237,0.15); }
.room-row .check { color: var(--green); font-weight: 800; }

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 10px;
  padding: 4px 18px 14px;
}
.stat {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 6px;
  text-align: center;
}
.stat-value { font-size: 18px; font-weight: 800; }
.stat-label { font-size: 11px; color: var(--text-dim); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }

/* Feed */
.feed {
  flex: 1;
  overflow-y: auto;
  padding: 4px 18px 100px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  margin-top: 60px;
  line-height: 1.5;
}
.empty-emoji { font-size: 40px; margin-bottom: 8px; }

.request-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  animation: pop-in 0.2s ease;
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.request-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.request-item { font-weight: 700; font-size: 16px; }
.request-price { font-weight: 800; color: var(--purple-light); font-size: 16px; white-space: nowrap; }
.request-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.request-note { margin-top: 10px; font-size: 14px; color: var(--text); background: rgba(255,255,255,0.04); border-radius: 10px; padding: 10px 12px; }

.request-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--purple-light);
  text-decoration: none;
}
.request-link:active { opacity: 0.7; }

.link-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
}
.link-preview-img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(255,255,255,0.08);
}
.link-preview-text { min-width: 0; }
.link-preview-title {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-preview-domain {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
}
.link-preview.loading { color: var(--text-dim); font-size: 13px; padding: 10px 12px; }

.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  margin-top: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-pending { background: rgba(167,139,250,0.18); color: var(--purple-light); }
.status-approved { background: rgba(52,211,153,0.18); color: var(--green); }
.status-denied { background: rgba(248,113,113,0.18); color: var(--red); }

.response-note {
  margin-top: 8px;
  font-size: 13.5px;
  font-style: italic;
  color: var(--text-dim);
  border-left: 3px solid var(--border);
  padding-left: 10px;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.card-actions button {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.card-actions .respond-btn { background: rgba(124,58,237,0.25); color: var(--purple-light); }

/* FAB */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  font-size: 30px;
  font-weight: 400;
  color: white;
  background: linear-gradient(135deg, var(--purple), #9333ea);
  box-shadow: 0 8px 24px rgba(124,58,237,0.5);
  cursor: pointer;
  line-height: 0;
}
.fab:active { transform: scale(0.94); }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}
.modal {
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  padding-bottom: calc(env(safe-area-inset-bottom) + 20px);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h2 { margin: 0; font-size: 19px; }

.respond-summary {
  margin-top: 14px;
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}
.chip.selected { background: var(--purple); border-color: var(--purple); color: white; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111;
  color: white;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

@media (min-width: 480px) {
  #onboarding, .respond-modal { align-items: center; }
  .modal-overlay { align-items: center; justify-content: center; }
  .modal { max-width: 420px; border-radius: var(--radius); }
}
