/* WC Caller — "After dark" theme */

:root {
  --bg: #15112b;
  --card: #1f1940;
  --card-2: #282154;
  --line: #2d2659;
  --text: #f2efff;
  --muted: #a39dd0;
  --lime: #c8ff3e;
  --pink: #ff4fa3;
  --violet: #9b4dff;
  --sky: #7fd8ff;
  --danger: #ff6b7d;
  --warn: #ffb547;
  --on-lime: #15112b;
  --radius: 20px;
  --font: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0 auto;
  max-width: 600px;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

body:has(dialog[open]) { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--sky); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

.icon { display: inline-flex; }
.icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ─── Top bar ─────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  padding: 4px 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 14px var(--lime);
}

.top-actions { display: flex; align-items: center; gap: 6px; }
.account { position: relative; }

.bell { position: relative; color: var(--text); }
.bell-count {
  position: absolute;
  top: 3px;
  right: 1px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}

.avatar-btn { border: 0; background: none; padding: 0; border-radius: 50%; display: block; }
.avatar-btn .avatar { width: 36px; height: 36px; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--violet); }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 190px;
  padding: 6px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgb(0 0 0 / 0.45);
}
.menu-name {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-item { width: 100%; text-align: left; border: 0; background: none; padding: 10px; border-radius: 10px; font-weight: 500; }
.menu-item:hover { background: var(--line); }

/* ─── Buttons ─────────────────────────────────────────────── */

.primary-btn {
  border: 0;
  border-radius: 14px;
  padding: 9px 18px;
  background: var(--lime);
  color: var(--on-lime);
  font-weight: 700;
}
.primary-btn:disabled { opacity: 0.35; }
.primary-btn.small { padding: 7px 14px; font-size: 15px; border-radius: 12px; }
.primary-btn.wide { width: 100%; padding: 13px; }

.text-btn { border: 0; background: none; padding: 8px 4px; font-size: 16px; color: var(--text); }

.icon-btn {
  border: 0;
  background: none;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-grid;
  place-items: center;
  color: var(--lime);
}
.icon-btn:hover { background: var(--card-2); }
.icon-btn.active { background: var(--lime); color: var(--on-lime); }
.icon-btn .icon svg { width: 22px; height: 22px; }
.icon-btn.small { width: 32px; height: 32px; border-radius: 10px; color: var(--muted); }
.icon-btn.small .icon svg { width: 17px; height: 17px; }

.fab {
  position: fixed;
  right: max(18px, calc(50vw - 300px + 18px));
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 10;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--lime);
  color: var(--on-lime);
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 6px rgb(200 255 62 / 0.15), 0 10px 30px rgb(200 255 62 / 0.35);
}
.fab .icon svg { width: 28px; height: 28px; stroke-width: 2.6; }

.pill {
  position: fixed;
  top: calc(70px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  background: var(--pink);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 8px 24px rgb(255 79 163 / 0.45);
}

/* ─── Posts ───────────────────────────────────────────────── */

.feed { padding: 4px 12px 0; }

.card {
  margin: 0 0 12px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.post-head { display: flex; align-items: center; gap: 12px; }
.post-who { min-width: 0; flex: 1; }
.post-author { font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-time { display: block; color: var(--muted); font-size: 13px; }
.post-delete { margin-left: auto; align-self: flex-start; }

.avatar {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  background: var(--card-2);
}
.avatar-fallback {
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  color: var(--on-lime);
}
.avatar.mini { width: 26px; height: 26px; font-size: 12px; box-shadow: 0 0 0 2px var(--card); margin-left: -8px; }
.avatar.mini:first-child { margin-left: 0; }

.post-body { margin: 12px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; }

.post-media-link { display: block; }
.post-media {
  display: block;
  width: 100%;
  max-height: 520px;
  margin-top: 12px;
  object-fit: cover;
  border-radius: 16px;
  background: var(--card-2);
}
video.post-media { object-fit: contain; background: #000; }

.post-actions { display: flex; gap: 20px; margin: 10px 0 -6px -8px; }
.action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 44px;
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.action:hover { color: var(--text); }
.action.like.active { color: var(--pink); }
.action.like.active svg { fill: currentColor; }

/* ─── Meetups ─────────────────────────────────────────────── */

.meetup { margin-top: 14px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--lime);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tag .icon svg { width: 14px; height: 14px; }

.mt { display: flex; gap: 14px; align-items: center; margin-top: 12px; }
.date-tile {
  flex-shrink: 0;
  width: 62px;
  padding: 8px 0;
  border-radius: 16px;
  background: var(--bg);
  color: var(--lime);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}
.date-tile b { font-size: 28px; font-weight: 700; }
.date-tile small { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.mt-info { min-width: 0; }
.mt-title { font-size: 18px; font-weight: 700; line-height: 1.25; white-space: pre-wrap; overflow-wrap: anywhere; }
.mt-time { margin-top: 4px; font-size: 14px; color: var(--muted); }

.rsvp-row { display: flex; gap: 8px; margin-top: 14px; }
.rsvp-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  background: var(--card-2);
  color: var(--text);
  font-weight: 700;
}
.rsvp-btn:disabled { opacity: 0.45; }
.rsvp-btn.coming.active { background: var(--lime); color: var(--on-lime); }
.rsvp-btn.not.active { background: var(--text); color: var(--bg); }
.rsvp-count {
  min-width: 24px;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 18%, transparent);
  font-size: 13px;
}

.going { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 14px; color: var(--muted); }
.stack { display: inline-flex; }

.meetup-cal {
  display: inline-block;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--lime);
}

/* Upcoming meetups glow */
.card.hot {
  border: 0;
  background: linear-gradient(150deg, var(--pink) 0%, var(--violet) 100%);
  color: #fff;
  box-shadow: 0 12px 34px rgb(155 77 255 / 0.35);
}
.card.hot .post-time,
.card.hot .action,
.card.hot .mt-time,
.card.hot .going { color: rgb(255 255 255 / 0.85); }
.card.hot .action:hover { color: #fff; }
.card.hot .action.like.active { color: #fff; }
.card.hot .post-delete { color: rgb(255 255 255 / 0.85); }
.card.hot .icon-btn.small:hover { background: rgb(0 0 0 / 0.18); }
.card.hot .tag { background: rgb(21 17 43 / 0.28); color: #fff; }
.card.hot .date-tile { background: var(--bg); }
.card.hot .rsvp-btn { background: rgb(21 17 43 / 0.28); color: #fff; }
.card.hot .rsvp-btn.coming.active { background: var(--lime); color: var(--on-lime); }
.card.hot .rsvp-btn.not.active { background: #fff; color: var(--bg); }
.card.hot .avatar.mini { box-shadow: 0 0 0 2px #c44bd6; }
.card.hot a { color: #fff; }
.card.hot .meetup-cal { color: var(--lime); }

.meetup.over .tag { color: var(--muted); }
.meetup.over .date-tile { color: var(--muted); }

.status {
  margin: 0;
  padding: 28px 16px calc(110px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--muted);
}
.status:empty { padding: 0; }
#sentinel { height: 1px; }

/* ─── Sheets (composer, thread, notifications) ────────────── */

/* --vv-height / --vv-top track the part of the screen not covered by the
   on-screen keyboard (set from app.js), so the toolbar stays visible above it. */
dialog.sheet {
  position: fixed;
  top: var(--vv-top, 0px);
  bottom: auto;
  width: 100%;
  max-width: 100%;
  height: var(--vv-height, 100dvh);
  max-height: var(--vv-height, 100dvh);
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--text);
}
dialog.sheet::backdrop { background: rgb(8 6 20 / 0.7); }

@media (min-width: 640px) {
  dialog.sheet {
    top: 0;
    max-width: 600px;
    height: auto;
    max-height: 85dvh;
    margin: 6dvh auto auto;
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: 0 30px 80px rgb(0 0 0 / 0.55);
  }
}

.sheet-inner { display: flex; flex-direction: column; height: 100%; max-height: inherit; }

.sheet-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--line);
}
.sheet-head > :first-child { justify-self: start; }
.sheet-head > :last-child { justify-self: end; }
.sheet-title { font-weight: 700; font-size: 17px; }

.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
#composer .sheet-body { padding: 14px 16px; }

.sheet-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

#post-text {
  width: 100%;
  border: 0;
  outline: none;
  resize: none;
  background: none;
  font-size: 20px;
  line-height: 1.4;
  min-height: 120px;
}
#post-text::placeholder { color: var(--muted); }

.char-count { margin-left: auto; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.char-count.warn { color: var(--warn); }
.char-count.over { color: var(--danger); font-weight: 700; }

.media-preview { position: relative; margin-top: 10px; }
.media-preview img, .media-preview video {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  border-radius: 16px;
  background: var(--card);
}
.remove-media {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgb(8 6 20 / 0.75);
  color: #fff;
  font-size: 22px;
  line-height: 1;
}

.meetup-fields {
  margin: 14px 0 0;
  padding: 14px;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(150deg, var(--pink) 0%, var(--violet) 100%);
}
.meetup-fields legend {
  float: left;
  width: 100%;
  margin-bottom: 10px;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
}
.meetup-grid { clear: both; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meetup-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: rgb(255 255 255 / 0.9); }
.meetup-grid label:last-child { grid-column: 1 / -1; }
.meetup-grid input, .meetup-grid select {
  width: 100%;
  min-height: 46px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* 16px stops iOS from zooming in */
}
.field-error { margin: 10px 0 0; color: #fff; font-size: 14px; font-weight: 700; }

/* Thread */
#thread-post { padding: 12px 12px 0; }
#thread-post .card { margin-bottom: 4px; }
.comments { padding: 4px 0 12px; }
.comment {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.comment .avatar { width: 36px; height: 36px; }
.comment .post-head { gap: 8px; }
.comment .post-time { display: inline; }
.comment .post-body { margin-top: 2px; }
.post-main { min-width: 0; }
.comments .status { padding: 28px 16px; }

.comment-form { display: flex; align-items: flex-end; gap: 8px; width: 100%; }
.comment-form textarea {
  flex: 1;
  min-height: 46px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  resize: none;
  outline: none;
  font-size: 16px;
}
.comment-form textarea::placeholder { color: var(--muted); }
.comment-form textarea:focus { border-color: var(--violet); }
.comment-form .primary-btn { min-height: 46px; }

/* ─── Notifications ───────────────────────────────────────── */

.push-banner {
  margin: 4px 12px 14px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--lime);
  box-shadow: 0 0 24px rgb(200 255 62 / 0.12);
}
.push-banner p, .push-settings p { margin: 0 0 12px; }
.banner-title { font-weight: 700; font-size: 17px; margin-bottom: 4px; }
.push-banner ol, .push-settings ol { margin: 0 0 12px; padding-left: 20px; }
.push-banner li, .push-settings li { margin: 4px 0; }
.muted { color: var(--muted); font-size: 15px; }
.banner-actions { display: flex; align-items: center; gap: 12px; }
.banner-actions .text-btn { color: var(--muted); font-size: 15px; }

.push-settings { padding: 16px; border-bottom: 1px solid var(--line); }
.push-settings .text-btn { color: var(--lime); font-weight: 700; padding-left: 0; }

.inbox-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
}
.inbox-item.unread { background: color-mix(in srgb, var(--violet) 16%, var(--bg)); }
.inbox-item.unread .inbox-text::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--pink);
  vertical-align: middle;
}
.inbox-text { margin: 0; }
.inbox-meta { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ─── Toast ───────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 100;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.5);
}

[hidden] { display: none !important; }
