/* Simple, responsive, self-contained stylesheet (no build step required). */
:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #2b303b;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --accent-hover: #6ea0ff;
  --danger: #e5484d;
  --ok: #30a46c;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* The [hidden] attribute must win over component display rules (e.g. flex),
   otherwise elements toggled via .hidden in JS stay visible. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

/* Header / nav */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 0;
  flex-wrap: wrap;
}
.nav .brand { font-weight: 700; font-size: 1.15rem; color: var(--text); }
.nav .spacer { flex: 1; }
.nav a { color: var(--muted); font-size: .95rem; }
.nav a:hover { color: var(--text); }
.nav form { display: inline; }
.nav-profile { display: inline-flex; align-items: center; }
.nav-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: block;
}

/* Mentions */
.mention { color: var(--accent); font-weight: 600; }
.mention-dropdown {
  position: absolute;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  overflow: hidden;
  max-height: 240px;
  overflow-y: auto;
}
.mention-option { padding: .4rem .6rem; cursor: pointer; font-size: .9rem; white-space: nowrap; }
.mention-option.active, .mention-option:hover { background: var(--surface-2); }
.mention-handle { color: var(--muted); font-size: .8rem; }

/* Reactions: toggle button + who-reacted hover popup */
.reaction-wrap { position: relative; display: inline-flex; }
.reaction-btn { font-size: 1.05rem; padding: .2rem .55rem; border-radius: .4rem; }
.reaction-btn.mine { background: #1e3a8a; color: #fff; }
.reaction-count { font-size: .78rem; }
.reactors-popup {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: .35rem;
  z-index: 50;
  min-width: 150px;
  max-width: 240px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  padding: .35rem 0;
}
.reaction-wrap:hover .reactors-popup { display: block; }
.reactors-head { padding: .2rem .6rem .35rem; font-weight: 600; font-size: .8rem; border-bottom: 1px solid var(--border); margin-bottom: .25rem; }
.reactor { padding: .12rem .6rem; font-size: .82rem; white-space: nowrap; }

/* Top-bar message icon + notification counter + popup */
.nav-msg { position: relative; display: inline-flex; font-size: 1.1rem; }
.nav-profile-wrap { position: relative; display: inline-flex; }

/* Messages */
.convo-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .15rem 1rem;
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.convo-row:hover { background: var(--surface-2); }
.convo-name { font-weight: 600; }
.convo-preview { grid-column: 1; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-time { grid-column: 2; grid-row: 1; font-size: .78rem; }
.msg-thread { display: flex; flex-direction: column; gap: .4rem; max-height: 60vh; overflow-y: auto; }
.msg { max-width: 75%; padding: .4rem .65rem; border-radius: var(--radius); }
.msg .msg-body { white-space: pre-wrap; }
.msg.mine { align-self: flex-end; background: #1e3a8a; color: #fff; }
.msg.theirs { align-self: flex-start; background: var(--surface-2); }
.msg-time { font-size: .68rem; margin-top: .15rem; }
.msg-sender { font-size: .72rem; font-weight: 600; opacity: .85; margin-bottom: .1rem; }
.msg-edited { font-size: .62rem; font-style: italic; opacity: .8; margin-left: .3rem; }
.msg-reply-btn { font-size: .68rem; padding: 0; }
/* Cited (quoted) message shown inside a reply bubble */
.msg-quote {
  display: block;
  border-left: 3px solid currentColor;
  padding: .15rem .45rem;
  margin-bottom: .25rem;
  border-radius: 4px;
  background: rgba(127, 127, 127, .14);
  font-size: .78rem;
  text-decoration: none;
  color: inherit;
  opacity: .92;
}
.msg-quote-name { font-weight: 600; display: block; }
.msg-quote-text { display: block; opacity: .85; }
/* Composer citation preview */
.reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  border-left: 3px solid var(--accent, #4f8cff);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: .3rem .5rem;
  margin-bottom: .4rem;
  font-size: .8rem;
}
.reply-preview-name { font-weight: 600; margin: 0 .3rem; }
/* Message attachments */
.msg-attachments { display: flex; flex-wrap: wrap; gap: .4rem; margin: .25rem 0; }
.msg-att-img img { max-width: 200px; max-height: 200px; border-radius: 6px; display: block; }
.msg-att-file {
  display: inline-block;
  padding: .3rem .5rem;
  background: rgba(127, 127, 127, .14);
  border-radius: 6px;
  font-size: .82rem;
  text-decoration: none;
  color: inherit;
}
.revision { padding: .5rem 0; border-top: 1px solid var(--border); }
.revision:first-child { border-top: none; }
.revision.current .revision-body { font-weight: 500; }
.revision-meta { font-size: .75rem; margin-bottom: .25rem; }
.revision-body { white-space: pre-wrap; }
.role-badge { font-size: .8em; margin-left: .25rem; vertical-align: baseline; cursor: help; }
.group-manage > summary { list-style: none; cursor: pointer; display: inline-block; }
.group-manage > summary::-webkit-details-marker { display: none; }
.badge-count {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: .68rem;
  line-height: 16px;
  text-align: center;
  font-weight: 700;
}
.notif-popup {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: .4rem;
  width: 300px;
  max-width: 84vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  z-index: 60;
  overflow: hidden;
}
/* An invisible bridge over the gap between the avatar and the popup, so moving
   the cursor down to click an item doesn't cross dead space and close it. */
.notif-popup::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  height: .5rem;
}
.nav-profile-wrap:hover .notif-popup,
.nav-profile-wrap.open .notif-popup { display: block; }
.notif-popup-head { padding: .5rem .75rem; font-weight: 600; border-bottom: 1px solid var(--border); }
.notif-item {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: .85rem;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: rgba(79, 140, 255, .12); }
.notif-time { font-size: .72rem; white-space: nowrap; }
.notif-empty { padding: .75rem; font-size: .85rem; }

/* Buttons */
.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: .5rem .9rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: .95rem;
}
.btn:hover { background: var(--accent-hover); color: #fff; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.link { background: none; color: var(--muted); padding: .25rem; }
.btn.whatsapp { background: #25d366; color: #0b3d20; }
.btn.whatsapp:hover { background: #1ebe5b; color: #0b3d20; }

/* Cards / grid */
main { padding: 1.5rem 0 3rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: block;
  position: relative;
}
.tile img, .tile .thumb-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}
.thumb-placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: .85rem;
}
.tile .caption { padding: .5rem .6rem; font-size: .85rem; color: var(--text); }
.tile .meta { color: var(--muted); font-size: .75rem; }

/* "That's not me" correction, overlaid on a matched-photo tile. */
.tile-cell { position: relative; }
.not-me-overlay { position: absolute; top: .4rem; right: .4rem; margin: 0; }
.not-me-overlay button {
  font-size: .72rem;
  padding: .2rem .5rem;
  color: #fff;
  background: rgba(0, 0, 0, .6);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}
.not-me-overlay button:hover { background: rgba(0, 0, 0, .8); }

.badge {
  display: inline-block;
  font-size: .7rem;
  padding: .15rem .45rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.badge.pending { color: #f5a623; border-color: #5a4520; }
.badge.ready { color: var(--ok); border-color: #1f5138; }
.badge.failed { color: var(--danger); border-color: #5a2426; }
.badge.video { position: absolute; top: .4rem; right: .4rem; background: rgba(0,0,0,.6); color:#fff; }

/* Forms */
form .field { margin-bottom: 1rem; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .25rem; }
input, textarea, select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .55rem .65rem;
  font-size: .95rem;
  font-family: inherit;
}
input[type="checkbox"] { width: auto; }
.helptext { color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: .25rem 0; font-size: .85rem; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li {
  padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: .5rem;
  border: 1px solid var(--border); background: var(--surface);
}
.messages li.success { border-color: var(--ok); }
.messages li.error { border-color: var(--danger); }

/* Breadcrumbs */
.breadcrumbs { color: var(--muted); font-size: .85rem; margin-bottom: 1rem; }
.breadcrumbs a { color: var(--muted); }

/* Layout helpers */
.row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.25rem; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: 1rem 0; }
.toolbar form { display: flex; gap: .5rem; flex-wrap: wrap; }
.prose { max-width: 70ch; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); }

/* Media detail / lightbox */
.viewer {
  background: #000;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 75vh;
  overflow: hidden;
}
.viewer img, .viewer video { max-width: 100%; max-height: 75vh; display: block; }
.nav-arrows { display: flex; justify-content: space-between; margin-top: 1rem; }

/* Upload drop zone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  transition: border-color .15s, background .15s;
}
.dropzone.dragover { border-color: var(--accent); background: var(--surface-2); color: var(--text); }
#file-list { margin-top: 1rem; font-size: .9rem; color: var(--muted); }

/* Language switcher */
.lang-switch { display: inline; }
.lang-switch select {
  width: auto;
  padding: .3rem .5rem;
  font-size: .85rem;
}

/* Crew tiles (button reset) */
.crew-tile {
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  padding: 0;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  z-index: 50;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 1rem;
  overflow-y: auto;
}
.modal.open { display: flex; }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  padding: 1.5rem;
  position: relative;
}
.modal-close {
  position: absolute;
  top: .5rem;
  right: .75rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.crew-detail figure { margin: 0; }
.crew-detail figcaption { font-size: .8rem; margin-top: .25rem; }

/* Facebook-style composer */
.emoji-wrap { position: relative; display: inline-flex; }
.emoji-panel {
  display: none;          /* hidden until the button is hovered/opened */
  position: absolute;
  bottom: 100%;           /* float above the button as an overlay */
  left: 0;
  margin-bottom: .35rem;
  z-index: 40;
  flex-wrap: wrap;
  gap: .15rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem;
  width: 300px;
  max-width: 80vw;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
/* A small invisible bridge so moving the cursor from button to panel
   doesn't cross a gap that would drop the :hover state. */
.emoji-panel::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: .35rem;
}
.emoji-wrap:hover .emoji-panel,
.emoji-wrap.open .emoji-panel { display: flex; }
.emoji-cell {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: .2rem .25rem;
  border-radius: .35rem;
}
.emoji-cell:hover { background: var(--border); }

.composer-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .5rem;
}
.composer-previews:not(:empty) { margin-top: .5rem; }
.preview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
}
.preview-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: #000;
}
.preview-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-remove {
  position: absolute;
  top: .25rem;
  right: .25rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.preview-remove:hover { background: var(--danger); }
.preview-name {
  font-size: .7rem;
  color: var(--muted);
  padding: .25rem .35rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-card select { font-size: .8rem; padding: .25rem; margin: .25rem; width: calc(100% - .5rem); }

footer.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .85rem;
  padding: 1.5rem 0;
}

/* Push permission banner + onboarding modal */
.push-banner {
  display: flex; flex-wrap: wrap; gap: .5rem;
  align-items: center; justify-content: space-between;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .6rem .85rem; margin-bottom: 1rem;
}
.push-banner-actions { display: flex; gap: .5rem; align-items: center; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; padding: 1rem;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center;
}
body.modal-open { overflow: hidden; }
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); max-width: 560px; width: 100%;
  padding: 1.5rem; max-height: 90vh; overflow: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.intro-list { list-style: none; padding: 0; margin: 1rem 0; display: flex; flex-direction: column; gap: .7rem; }
.intro-list li { line-height: 1.45; }
