:root {
  --bg: #0b1020;
  --panel: #121a30;
  --panel-2: #18233f;
  --text: #eef2ff;
  --muted: #aab4d4;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #7c9cff;
  --accent-2: #9f7cff;
  --danger: #ff6b6b;
  --danger-2: #ff3f7c;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(124, 156, 255, 0.18), transparent 35%),
    radial-gradient(circle at 80% 20%, rgba(159, 124, 255, 0.18), transparent 25%),
    var(--bg);
  color: var(--text);
}
body { min-height: 100vh; }
body.drawer-open { overflow: hidden; }
input, button { font: inherit; }
.hidden { display: none !important; }
.small-text { font-size: 0.85rem; }
.muted { color: var(--muted); }
.text-link { display: inline-block; color: #cdd7ff; text-decoration: none; }
.eyebrow {
  margin: 0 0 8px;
  color: #c5d0ff;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 700;
}
h1 { margin: 0; line-height: 1.05; }
input {
  min-width: 0;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(8, 12, 24, 0.65);
  color: var(--text);
  padding: 14px 16px;
}
.primary-btn, .secondary-btn, .danger-btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
}
.primary-btn { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; }
.secondary-btn { background: rgba(255, 255, 255, 0.08); color: var(--text); border: 1px solid var(--border); }
.danger-btn { background: linear-gradient(135deg, var(--danger), var(--danger-2)); color: white; }
.compact-btn { padding: 8px 12px; border-radius: 10px; }
.badge, .admin-pill, .you-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: #d8e0ff;
  font-weight: 700;
  font-size: 0.82rem;
}
.admin-pill, .you-pill {
  min-height: auto;
  padding: 4px 8px;
  font-size: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.brand-room {
  margin-bottom: 8px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  display: block;
  flex: 0 0 auto;
}

.brand-name {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--text);
}
@media (max-width: 640px) {
  .brand-room .brand-logo {
    width: 28px;
    height: 28px;
  }

  .brand-room .brand-name {
    font-size: 1rem;
  }
}
.shell { width: min(100%, 1100px); margin: 0 auto; padding: 32px 20px; }
.center-shell { min-height: 100vh; display: grid; place-items: center; }
.card {
  width: 100%;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.hero-card { max-width: 820px; padding: 40px; }
.hero-card-compact { max-width: 760px; }
.subtext {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
  max-width: 70ch;
}
.quick-create-grid {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.quick-create-btn {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
}
.quick-create-btn:hover { transform: translateY(-2px); border-color: rgba(255,255,255,0.22); }
.quick-create-btn:disabled { opacity: 0.72; cursor: wait; }
.quick-create-private { background: linear-gradient(180deg, rgba(124,156,255,0.22), rgba(124,156,255,0.1)); }
.quick-create-admin { background: linear-gradient(180deg, rgba(159,124,255,0.22), rgba(159,124,255,0.1)); }
.quick-create-title { display: block; font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }
.quick-create-desc { display: block; color: var(--muted); line-height: 1.5; font-size: 0.95rem; }
.room-page { min-height: 100vh; min-height: 100dvh; }
.room-app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; max-width: 100%; }
.room-header {
  flex-shrink: 0;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 13, 26, 0.88);
  backdrop-filter: blur(14px);
}
.room-header-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.room-title-block h1 { font-size: clamp(1.1rem, 5vw, 1.7rem); }
.room-meta-inline { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.room-actions-desktop { display: none; gap: 10px; align-items: center; }
.room-actions-mobile { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.mobile-half-btn { width: 100%; }
.room-body { flex: 1; min-height: 0; display: block; }
.desktop-people-panel { display: none; }
.chat-panel {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto auto;
  background: rgba(8, 12, 24, 0.36);
}
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.empty-state { margin: auto; color: var(--muted); text-align: center; }
.message { max-width: 92%; }
.message-self { align-self: flex-end; }
.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.person-dot { width: 12px; height: 12px; border-radius: 999px; flex: 0 0 auto; }
.person-name { font-weight: 600; }
.message-bubble {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  line-height: 1.5;
  word-break: break-word;
  display: grid;
  gap: 10px;
}
.message-self .message-bubble { background: rgba(124, 156, 255, 0.14); }
.message-text { white-space: pre-wrap; word-break: break-word; }
.message-text-with-image { border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 10px; }
.message-image-wrap { display: grid; gap: 8px; }
.message-image {
  display: block;
  max-width: min(100%, 320px);
  max-height: 280px;
  width: auto;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}
.message-image-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.download-icon-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
  color: white;
  background: rgba(9, 13, 26, 0.78);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.22);
}

.download-icon-btn:hover {
  background: rgba(20, 28, 50, 0.92);
}
.message-image-meta, .message-kind-pill { font-size: 0.78rem; color: var(--muted); }
.message-kind-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.04);
}
.delete-msg-btn {
  margin-left: auto;
  border: 1px solid var(--border);
  background: transparent;
  color: #ffd5df;
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
}
.typing-bar {
  min-height: 38px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  color: #cdd7ff;
  font-size: 0.92rem;
  background: rgba(255, 255, 255, 0.02);
}
.upload-status { min-height: 22px; padding: 0 14px 12px; font-size: 0.9rem; }
.upload-status.info { color: #cdd7ff; }
.upload-status.success { color: #9ef0c4; }
.upload-status.error { color: #ffb4c1; }
.composer {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: rgba(9, 13, 26, 0.92);
  backdrop-filter: blur(14px);
}
.composer-main { display: grid; gap: 10px; }
.composer-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.file-btn { display: inline-flex; align-items: center; justify-content: center; text-align: center; }
.selected-image {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.drawer-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 82dvh;
  background: linear-gradient(180deg, rgba(18, 26, 48, 0.98), rgba(8, 12, 24, 0.98));
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 12px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}
.drawer-handle {
  width: 54px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 auto 14px;
}
.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.people-header { font-size: 0.95rem; color: var(--muted); margin-bottom: 6px; }
.people-list { display: flex; flex-direction: column; gap: 10px; }
.person-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  flex-wrap: wrap;
}
.image-rules { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.image-rules ul { margin: 8px 0 0 18px; padding: 0; color: var(--muted); line-height: 1.5; }
.drawer-actions { margin-top: 18px; display: grid; gap: 10px; }
.drawer-link { margin-top: 16px; }
@media (min-width: 900px) {
  .room-app { width: min(1200px, 100%); margin: 0 auto; }
  .room-header { padding: 18px 22px 14px; }
  .room-actions-desktop { display: flex; }
  .room-actions-mobile { display: none; }
  .room-body {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 18px;
    padding: 18px 22px 22px;
    min-height: 0;
  }
  .desktop-people-panel {
  display: block;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(8, 12, 24, 0.72);
  padding: 16px;
  overflow-y: auto;
  min-height: 0;
}
  .chat-panel {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto auto;
  background: rgba(8, 12, 24, 0.36);
}
  .drawer { display: none !important; }
  .message-image { max-width: min(100%, 420px); max-height: 360px; }
}
@media (max-width: 760px) {
  .quick-create-grid { grid-template-columns: 1fr; }
  .hero-card { padding: 24px; }
}
@media (max-width: 480px) {
  .room-header { padding-left: 12px; padding-right: 12px; }
  .messages { padding: 12px; }
  .composer { padding-left: 12px; padding-right: 12px; }
  .message { max-width: 100%; }
  .composer-actions { grid-template-columns: 1fr 1fr; }
  .primary-btn, .secondary-btn, .danger-btn { padding: 13px 14px; }
}

.messages-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.jump-to-latest {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 4;
  border: 1px solid var(--border);
  background: rgba(18, 26, 48, 0.96);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.jump-to-latest:hover {
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .modal-panel {
    width: calc(100vw - 24px);
    padding: 18px;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

.toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: rgba(18, 26, 48, 0.96);
  box-shadow: var(--shadow);
  color: var(--text);
  font-weight: 600;
}

.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-color: rgba(80, 220, 160, 0.35);
}

.toast-error {
  border-color: rgba(255, 107, 107, 0.35);
}

.toast-info {
  border-color: rgba(124, 156, 255, 0.35);
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
}

.modal-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(92vw, 460px);
  transform: translate(-50%, -50%);
  border-radius: 22px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(18, 26, 48, 0.98), rgba(8, 12, 24, 0.98));
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-header {
  margin-bottom: 10px;
}

.modal-title {
  margin: 0;
  font-size: 1.2rem;
}

.modal-message {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.55;
}

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

.modal-link-input {
  width: 100%;
  margin-bottom: 16px;
}
