:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --text: #0e1022;
  --muted: #666d85;
  --muted-soft: #aeb3c62b;
  --primary: #5c5ce7;
  --primary-fade: #5c5ce759;
  --primary-soft: #eeecff;
  --green: #22c55e;
  --green-soft: #dfeee5;
  --orange: #f59e0b;
  --danger: #ef4444;
  --danger-soft: #f6bebe;
  --line: #e8e9f2;
}

[data-theme="dark"] {
  --bg: #0b0c16;          /* Deep midnight navy/black */
  --surface: #211440;     /* Sleek dark slate for cards and containers */
  --text: #f3f4f6;        /* Bright, high-contrast off-white */
  --text-soft: #d1d5db;
  --muted: #8d95b0;       /* Softer grey-blue for readable secondary text */
  --muted-soft: #484e69;  /* Darker grey-blue for subtle hints/disabled states */
  --primary: #a4a4fe;     /* Lightened periwinkle for contrast and glow */
  --primary-fade: #8282ffc2;
  --primary-soft: #442891;/* Deep periwinkle/indigo tint for background badges */
  --green: #4ade80;       /* Brightened pastel green for dark mode accessibility */
  --green-soft: #102a1d;  /* Deep muted forest tint for success background badges */
  --orange: #fbbf24;      /* Brightened pastel orange */
  --danger: #f87171;      /* Brightened pastel red */
  --danger-soft: #480a0a;
  --line: #3b4376;        /* Subtle dark divider line */
}

/* Vibrant Pastel Mix */
/* :root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --text: #0e1022;
  --muted: #666d85;
  --muted-soft: #aeb3c6;
  --primary: #7c7bff;     
  --primary-soft: #f0efff;
  --green: #22c55e;
  --orange: #f59e0b;
  --danger: #ef4444;
  --line: #e3e4f0;        
} */

* {
  box-sizing: border-box;
  scrollbar-color: var(--primary-soft) var(--bg); /* thumb track */
  scrollbar-width: thin;          /* or "auto" / "none" */
}

/* WebKit-based browsers (Safari, older Chrome/Edge) */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--bg);
}

*::-webkit-scrollbar-thumb {
  background: var(--primary-soft);
  border-radius: 6px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--primary-fade);
}

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

/* Allow text to be split to a several lines */
h1, h2, h3, h4, h5, h6, p, span, div {
  overflow-wrap: anywhere;
}

/* Limit line length to 2 lines */
h1, h2, h3, h4, h5, h6 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.app-shell {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  /* background: linear-gradient(
    90deg,
    var(--bg) 0%,
    var(--bg) 50%,
    var(--primary-soft) 100%
  ); */
}

.app-header {
  /* background: var(--surface); */
  background: linear-gradient(
    90deg,
    var(--bg) 0%,
    var(--bg) 50%,
    var(--primary) 100%
  );
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.app-brand {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  /* gap: 10px; */
}

.header-icon-btn {
  width: 48px;
  height: 48px;
  border: 0;
  background: transparent;
  border-radius: 14px;
  cursor: pointer;
  display: grid;
  place-items: center;


}

.header-icon-btn:active {
  background: var(--primary-soft);
}

#header-back {
  grid-column: 1;
  justify-self: start;
}

#header-profile {
  grid-column: 3;
  justify-self: end;
}

.header-icon-btn .action-icon {
  width: 30px;
  height: 30px;
  filter: brightness(0) saturate(100%) invert(36%) sepia(72%) saturate(2450%) hue-rotate(228deg)
    brightness(96%) contrast(92%);
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
}

.app-header h1 {
  margin: 0;
  font-size: 33.6px;
  line-height: 1;
}

.app-header h1 .brand-accent {
  color: var(--primary);
}

.app-header h1 .brand-accent-soft {
  color: var(--muted);
}

main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* padding: 0px 14px 0px; */
}

.view {
  display: none;
}

.view.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  background: var(--primary-soft);
  border-radius: 12px;
  padding: 4px;
  margin: 14px 0 14px 0;
}

.space-tabs {
  grid-template-columns: repeat(4, 1fr);
}

.requests-tabs {
  grid-template-columns: repeat(3, 1fr);
}

.space-tabs .segment {
  font-size: 15.6px;
  padding: 8px 4px;
}

.segment {
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  border-radius: 8px;
  padding: 9px;
}

.segment.active {
  background: var(--bg);
  color: var(--text);
}

.segment-panel {
  display: none;
}

.segment-panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.segment-text {
  display: inline-flex;
  align-items: center;
  gap: 6px; /* space between icon and text */
}

.form-icon-btn {
  border: 0;
  background: transparent;
  padding: 10px 8px;
  color: var(--muted);
  font-size: 14.4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.primary-btn,
.secondary-btn,
.text-btn,
.ghost-icon-btn {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 16.8px;
  box-shadow: 1px 1px 5px 1px rgba(92, 92, 231, 0.35);
}

.primary-btn {
  width: 100%;
  background: var(--primary);
  color: var(--bg);
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  margin: 0 0 10px;
}

.primary-btn.success {
  /* background: var(--green); */
}

.secondary-btn {
  width: 100%;
  height: 44px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.secondary-btn.danger {
  color: var(--danger);
}

.secondary-btn.small,
.primary-btn.small {
  width: auto;
  padding: 0 16px;
}

.fab-btn {
  position: fixed;
  right: calc(50% - min(430px, 100vw) / 2 + 16px);
  bottom: calc(68px + env(safe-area-inset-bottom));
  z-index: 20;
  width: auto;
  height: 36px;
  padding: 0 14px;
  font-size: 15.6px;
  border-radius: 999px;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(92, 92, 231, 0.35);
}

/* .fab-btn .action-icon {
  width: 24px;
  height: 24px;
} */

.fab-btn.is-hidden {
  display: none;
}

.text-btn {
  background: transparent;
  color: var(--primary);
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ghost-icon-btn {
  width: 32px;
  height: 32px;
  background: transparent;
}

.list-stack {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 10px;
  padding: 0 0 5px;
}

.event-card {
  background: var(--bg);
  /* box-shadow: 0px 0px 5px 0px var(--primary); */
  border: 1px solid var(--primary);
  border-radius: 14px;
  overflow: hidden;
  /* padding: 12px; */
  margin: 4px;
  display: flex;
  /* align-items: center; */
  gap: 10px;
  cursor: pointer;
  position: relative;
}

.event-subscribe-count {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  line-height: 1;
  color: var(--muted);
  pointer-events: none;
}

.event-subscribe-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  opacity: 0.85;
}

.event-subscribe-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.event-details-card {
  display: flex;
  /* align-items: center; */
  gap: 10px;
  border-bottom: 1px solid var(--line);

}

.event-details-card-name {
  padding: 10px 10px 0 0;
  font-size: 18px;
  font-weight: 600;
  margin: 0;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#event-details-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: auto;
  min-height: 90px;
  /* align-self: center; */
}

/* #event-details-icon-wrapper:has(> img:not(.is-hidden)) {
  height: 160px;
} */


.event-content {
  flex: 1;
  margin: 4px 0 0 0;
  position: relative;
  overflow: hidden;
}

.event-content h3 {
  /* margin: 12px 0 12px; */
  font-size: 18px;
}

.space-card,
.space-choice {
  background: var(--bg);
  /* box-shadow: 0px 0px 5px 0px var(--primary); */
  border-radius: 16px;
  border: 1px solid var(--primary-fade);
  border-radius: 14px;
  /* padding: 12px; */
  margin: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}
[data-theme="dark"] .space-card {
  border: 1px solid var(--primary);
}

.space-content {
  flex: 1;
  padding: 8px 0 8px 0;
}

.space-content h3,
.review-card h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.event-content p,
.space-content p,
.review-card p,
.description,
.meta-line {
  margin: 0;
  font-size: 15.6px;
  color: var(--text-soft);
}

.event-content-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.event-content-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    rgba(0,0,0,0.65) 0%,
    rgba(0,0,0,0.30) 100%
  );
}

.event-content-body {
  position: relative;
  z-index: 2;
  padding: 10px 8px 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

/* White text when image is present */
.event-content.has-image h3 {
  color: #fff;
}

.event-content.has-image .space-type-icon {
  filter: brightness(0) invert(1);
}

.event-content.has-image ~ .chevron img {
  filter: brightness(0) invert(1);
}

.chevron {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.chevron img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(76%) sepia(10%) saturate(4200%) hue-rotate(203deg) brightness(103%) contrast(99%);
}

.avatar-row {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}

.avatar-ph {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f0f2ff;
  color: #4a4f67;
  font-size: 12px;
  display: grid;
  place-items: center;
}

.icon-ph {
  border: 1px dashed #a6abc1;
  color: #6d738e;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
}

.meta-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
  /* Muted grey that stays visible for both black SVGs and colored PNGs. */
  filter: brightness(0) saturate(100%) invert(55%);
}

.nav-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  /* Inactive tabs: visible grey (active state overrides to violet below). */
  filter: brightness(0) saturate(100%) invert(55%);
}

.nav-btn.active .nav-icon {
  opacity: 1;
  filter: brightness(0) saturate(100%) invert(76%) sepia(10%) saturate(4200%) hue-rotate(203deg) brightness(103%) contrast(99%);
}
[data-theme="dark"] .nav-btn.active .nav-icon {
  filter: brightness(0) saturate(100%) invert(36%) sepia(72%) saturate(2450%) hue-rotate(228deg)
  brightness(96%) contrast(92%);
}
/* .nav-btn.active .nav-icon {
  filter: brightness(100) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(0deg)
  brightness(100%) contrast(100%)
}
[data-theme="dark"] .nav-btn.active .nav-icon {
  opacity: 1;
  filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(0deg)
  brightness(100%) contrast(100%)
} */


.action-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
  /* Force any source (black SVG or colored PNG) to a clearly visible grey. */
  filter: brightness(0) saturate(100%) invert(45%);
}
/* Dark Mode Adaptation */
[data-theme="dark"] .action-icon {
  /* Dark Mode: Turns any source color into a clean, bright light grey (#d1d5db) */
  filter: brightness(100) saturate(100%) invert(0%);
}

.action-icon-sm {
  width: 20px;
  height: 20px;
  object-fit: contain;
  /* Force any source to a clearly visible grey (matches .action-icon). */
  filter: brightness(0) saturate(100%) invert(45%);
}

.action-icon-light {
  opacity: 1;
  filter: brightness(0) invert(1);
}
[data-theme="dark"] .action-icon-light {
    /* Dark Mode: Turns any source color into a clean, bright light grey (#d1d5db) */
    filter: brightness(0) saturate(100%) invert(0%);
  }

.action-icon-dark {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
  filter: brightness(0) saturate(100%) invert(100%);
}

.text-btn .action-icon {
  opacity: 1;
  filter: brightness(0) saturate(100%) invert(36%) sepia(72%) saturate(2450%) hue-rotate(228deg)
    brightness(96%) contrast(92%);
}

.icon-xs {
  width: 16px;
  height: 16px;
}

.icon-sm {
  width: 20px;
  height: 20px;
}

.event-icon {
  width: 90px;
  min-height: 90px;
  flex-shrink: 0;
  /* border-radius: 12px 0 0 12px; */
  overflow: hidden;
  background: var(--primary);
  position: relative;
  display: flex;
  flex-direction: column;
}

.event-icon-date-overlay {
  /* position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  background: color-mix(in srgb, var(--primary-soft) 80%, transparent); */
  /* color: var(--primary); */
  /* font-size: 11px; */
  color: var(--primary-soft);
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.02em;
  padding: 0px 0 4px 0;
  /* text-shadow: 0px 0px 3px var(--bg); */
}

.event-icon-details {
  width: 90px;
  min-height: 90px;
  flex-shrink: 0;
  border-radius: 12px 0 0 0;
  overflow: hidden;
  /* background: var(--primary-soft); */
}

.event-icon img,
.event-icon-details img {
  width: 100%;
  flex: 1;
  min-height: 0;
  object-fit: cover;
  object-position: center;
  display: block;
}

.event-icon-slot {
  display: flex;
}

.event-icon > .event-icon-date {
  width: 90px;
  height: 90px;
}

.event-icon > img.is-hidden,
.event-icon > .event-icon-date.is-hidden {
  display: none;
}

.event-icon-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--primary-soft);
  text-align: center;
  user-select: none;
}

.event-icon-day {
  font-size: 46px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.event-icon-month {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  opacity: 0.9;
}

.event-icon-date-empty .event-icon-day {
  font-size: 36px;
  opacity: 0.45;
}

.event-image-field {
  margin-bottom: 4px;
}

.event-image-picker {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-top: 8px;
}

.event-image-preview-wrap {
  width: 90px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--primary-soft);
}

.event-image-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.event-image-preview.is-hidden,
.event-image-preview-date.is-hidden {
  display: none;
}

.event-image-preview-date {
  min-height: 90px;
  width: 100%;
  height: 100%;
}

.event-image-actions {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 4px;
}

.event-image-choose {
  cursor: pointer;
  margin: 0 10px 0 10px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.space-icon {
  width: 42px;
  align-self: stretch;
  min-height: 42px;
  flex-shrink: 0;
  border-radius: 12px 0 0 12px;
  background: var(--primary-soft);
  display: grid;
  place-items: center;
}

.space-icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(36%) sepia(72%) saturate(2450%) hue-rotate(228deg)
    brightness(96%) contrast(92%);
}

.event-space-icons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 8px 0;
  /* ADD these to cap at 2 rows: */
  max-height: calc(24px * 2 + 6px); /* 2 icon rows + 1 row-gap */
  overflow: hidden;
}

.event-space-icons .space-type-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(36%) sepia(72%) saturate(2450%) hue-rotate(228deg)
    brightness(96%) contrast(92%);
}

/* Availability colors shared by the small event icons and the space-card icons. */
.event-space-icons .space-type-icon.icon-available,
.space-icon.state-available img {
  filter: brightness(0) saturate(100%) invert(52%) sepia(66%) saturate(520%) hue-rotate(92deg)
    brightness(95%) contrast(90%);
}

.event-space-icons .space-type-icon.icon-full,
.space-icon.state-full img {
  filter: brightness(0) saturate(100%) invert(36%) sepia(51%) saturate(2878%) hue-rotate(335deg)
    brightness(95%) contrast(92%);
}

.space-type-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* width: 24px; */
  height: 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  /* background: var(--primary-soft); */
  /* border: 1px solid var(--primary); */
  /* border-radius: 50%; */
}

.space-icon.state-available {
  background: var(--green-soft);
}

.space-icon.state-full {
  background: var(--danger-soft);
}

/* Circular avatar (Telegram photo with an initials fallback behind it). */
.avatar-wrap {
  position: relative;
  display: inline-flex;
  width: 28px;
  height: 28px;
  flex: none;
  vertical-align: middle;
}

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.avatar-img {
  position: absolute;
  inset: 0;
  background: var(--surface);
}

.avatar-wrap.avatar-sm {
  width: 20px;
  height: 20px;
}

.avatar-wrap.avatar-sm .avatar-fallback {
  font-size: 9px;
}

.avatar-wrap.avatar-lg {
  width: 72px;
  height: 72px;
}

.avatar-wrap.avatar-lg .avatar-fallback {
  font-size: 26px;
}

.avatar-wrap.avatar-header {
  width: 34px;
  height: 34px;
}

.avatar-wrap.avatar-header .avatar-fallback {
  font-size: 14px;
}

.space-members {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  /* No left/vertical padding so the avatar sits flush and fills the chip. */
  padding: 0 14px 0 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 15.6px;
  color: var(--text);
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
}

/* Inside a chip the avatar fills the full height (chip is 36px tall minus the
   1px border on each side), with no surrounding padding. */
.member-chip .avatar-wrap {
  width: 34px;
  height: 34px;
}

.member-chip .avatar-fallback {
  font-size: 13px;
}

.member-chip > .chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Clickable member: outline only, no fill. */
.member-chip-link {
  /* color: var(--primary); */
  border-color: var(--primary-fade);
  cursor: pointer;
}

/* Organizer: outline + filled background. */
.organizer-chip {
  /* color: var(--primary); */
  border-color: var(--primary-fade);
  background: var(--primary-soft);
}

.more-chip {
  padding: 0 14px 0 14px;
}

.spot-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.spot-name .spot-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spot-name-link {
  color: var(--primary);
  cursor: pointer;
}

.space-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 0 8px 0;
}

.space-spots {
  flex: 0 0 auto;
  font-size: 15.6px;
  color: var(--muted);
  white-space: nowrap;
}

.space-count-inline {
  font-weight: 600;
  font-size: 0.85em;
}

.space-count-inline.has-space {
  color: var(--green);
}

.space-count-inline.is-full {
  color: var(--danger);
}

.myspace-group-head {
  margin: 6px 0 0;
  padding: 0 2px;
  font-size: 0.85em;
  font-weight: 600;
  color: var(--text);
  overflow: visible;
}

.myspace-group-head:first-child {
  margin-top: 0;
}

.space-organizer-link {
  cursor: pointer;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(14, 16, 34, 0.45);
}

.modal-card {
  width: 100%;
  max-width: 320px;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 16px 40px rgba(14, 16, 34, 0.25);
}

.modal-card h3 {
  margin: 0 0 4px;
  font-size: 21.6px;
}

/* Browser login screen (shown outside Telegram until the user logs in). */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(14, 16, 34, 0.12);
}

.login-logo {
  width: 56px;
  height: 56px;
  margin-bottom: 8px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 30px;
}

.login-card h1 .brand-accent {
  color: var(--primary);
}

.login-card p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 15.6px;
}

.login-widget {
  display: flex;
  justify-content: center;
  min-height: 48px;
}

.login-tg-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--primary);
  font-size: 15px;
  text-decoration: none;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.modal-head-text {
  min-width: 0;
}

.modal-avatar {
  flex: none;
}

.profile-card-text {
  min-width: 0;
}

.profile-card-text h3 {
  margin: 0;
}

.profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.profile-head h2 {
  margin: 0;
}

.profile-card-avatar {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-card {
  padding: 14px;
}
/* 
.billing-card {
  margin-top: 16px;
} */

.billing-title,
.contact-title {
  margin: 0 0 4px;
  font-size: 18px;
}

.billing-note,
.contact-note {
  margin: 0 0 16px;
  font-size: 14.4px;
  color: var(--muted);
}

.billing-item + .billing-item {
  margin-top: 14px;
}

.billing-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15.6px;
  margin-bottom: 6px;
}

.billing-usage {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.billing-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  overflow: hidden;
}

.billing-bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.billing-bar.is-full > span {
  background: var(--danger);
}

.modal-username {
  margin: 0;
  font-size: 16.8px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-card .primary-btn {
  margin-bottom: 8px;
}

/* Disabled "Telegram is hidden" state: white button with a muted dark icon. */
.primary-btn.is-muted-disabled {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
  cursor: default;
}

/* Loading skeletons shown while async data is fetched. */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--primary-soft);
  border-radius: 6px;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: skeleton-shimmer 1.2s infinite;
}

@keyframes skeleton-shimmer {
  100% {
    transform: translateX(100%);
  }
}

.skeleton-line {
  display: block;
  height: 12px;
}

.skeleton-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.skeleton-badge {
  width: 56px;
  height: 18px;
  border-radius: 999px;
}

.skeleton-bar {
  display: block;
  height: 4px;
  margin-top: 10px;
  border-radius: 999px;
}

.space-card-skeleton,
.event-card-skeleton {
  pointer-events: none;
}

.spot-row-skeleton {
  align-items: center;
}

.progress-line {
  width: 100%;
  height: 6px;
  /* background: var(--primary-soft); */
  border: 1px solid var(--primary-fade);
  border-radius: 999px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-line span {
  display: block;
  height: 100%;
  background: var(--primary);
}

.progress-line.warning span {
  background: var(--orange);
}

.progress-line.success span {
  background: var(--green);
}

.progress-line.has-space span {
  background: var(--green);
}

.progress-line.is-full span {
  background: var(--danger);
  width: 100% !important;
}

.section-head {
  margin-top: 18px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  /* padding: 16px; */
  margin: 0 4px 4px 4px;;
  /* box-shadow: 1px 1px 5px 1px rgba(92, 92, 231, 0.35); */

}

.detail-card-space {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 16px 4px 16px;
}

/* Top action bar on the Event/Space detail pages: type label + edit/delete,
   kept on its own row so a long name can't push the buttons around. */
.detail-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0 12px 0;
}

.detail-bar-label {
  font-size: 16.8px;
  font-weight: 600;
  color: var(--muted);

  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-bar-label.pointer {
  color: var(--primary);
  /* border: 1px solid var(--primary-fade); */
  /* background: var(--bg); */
  /* border-radius: 10px; */
  /* height: 40px; */
  /* line-height: 1.6; */

  background: none;
  border: none;
  padding: 0;
  font: inherit;
}

.detail-actions-menu {
  position: relative;
  flex: 0 0 auto;
}

.detail-actions-dropdown {
  position: absolute;
  top: 50%;
  right: calc(100% + 4px);
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--primary-fade);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 20;
}

.detail-actions-menu.is-open .detail-actions-toggle {
  background: var(--primary);
}

/* Owner-only edit/delete group, hidden for non-owners while Copy/Share stay. */
.owner-actions {
  display: flex;
  gap: 8px;
}

/* Compact labelled action (e.g. "Link") that aligns with icon buttons. */
.pill-action {
  height: 40px;
  border: 1px solid var(--primary-fade);
  background: var(--bg);
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.icon-action {
  width: 40px;
  height: 40px;
  border: 1px solid var(--primary-fade);
  background: var(--bg);
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-action:active,
.pill-action:active {
  background: var(--primary);
}

.icon-action:disabled {
  opacity: 0.5;
  background: var(--muted-soft);
}

.icon-action img,
.pill-action img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

/* Edit: violet. */
.icon-action img,
.pill-action img {
  filter: brightness(0) saturate(100%) invert(36%) sepia(72%) saturate(2450%) hue-rotate(228deg) brightness(96%) contrast(92%);
}
[data-theme="dark"] .icon-action img,
[data-theme="dark"] .pill-action img {
  filter: brightness(0) saturate(100%) invert(60%) sepia(60%) saturate(800%) hue-rotate(210deg) brightness(115%) contrast(98%);
}

/* Delete: red. */
.icon-action.danger img {
  filter: brightness(0) saturate(100%) invert(33%) sepia(86%) saturate(2400%) hue-rotate(343deg)
    brightness(97%) contrast(95%);
}

.icon-action.danger {
  border-color: var(--danger-soft);
}
[data-theme="dark"] .icon-action.danger {
  border-color: var(--danger);
}

/* Subscribe: green.*/
.icon-action.success {
  border-color: var(--green);
}

.icon-action.success img {
  /* filter: brightness(0) saturate(100%) invert(72%) sepia(50%) saturate(600%) hue-rotate(90deg) brightness(105%) contrast(95%); */
  filter: brightness(0) saturate(100%) invert(52%) sepia(66%) saturate(520%) hue-rotate(92deg) brightness(95%) contrast(90%);
}
[data-theme="dark"] .icon-action.success img {
  filter: brightness(0) saturate(100%) invert(72%) sepia(50%) saturate(600%) hue-rotate(90deg) brightness(105%) contrast(95%);
}

/* Type tabs are locked while editing a space (type can't change). */
.space-tabs.tabs-locked {
  pointer-events: none;
  opacity: 0.55;
}

.detail-card .description:empty {
  margin: 0;
}

/* Stronger divider between the event details card and the Spaces list. */
.spaces-section-head {
  margin-top: 12px;
  gap: 12px;
}

.spaces-section-head h2 {
  margin: 0;
}

/* Inline divider that trails the heading: "Spaces ------------". */
.head-rule {
  flex: 1 1 auto;
  height: 1px;
  background: var(--line);
}

/* .space-requests-section {
  margin-top: 12px;
} */


.section-head h3,
h2 {
  margin: 0;
}

.back-btn {
  background: transparent;
  border: 0;
  color: var(--text);
  margin-bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
}

.meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.description {
  margin: 8px;
  white-space: pre-wrap;
}

.description.collapsed {
  /* display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; */
  overflow: hidden;
  padding: 0 0 18px 0;
}

.spot-list {
  background: var(--bg);
  border: 1px solid var(--primary-fade);
  border-radius: 14px;
  padding: 0 16px 0 16px;
  margin: 4px;
  /* box-shadow: 1px 1px 5px 1px rgba(92, 92, 231, 0.35); */
}

.spot-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.spot-delete-btn {
  width: 32px;
  height: 32px;
  padding: 0;
}

.spot-delete-btn img {
  width: 18px;
  height: 18px;
}

.spot-row:last-child {
  border-bottom: 0;
}

.badge {
  font-size: 13.2px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
}

.badge.organizer {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge.joined {
  background: var(--green-soft);
  color: var(--green);
  /* #eafaf0 */
}

.badge.muted {
  background: var(--muted-soft);
  color: var(--muted);
}

.request-item {
  background: var(--bg);
  border: 1px solid var(--primary-fade);
  border-radius: 14px;
  padding: 12px;
  margin: 4px 4px 14px 4px;
  /* box-shadow: 1px 1px 5px 1px rgba(92, 92, 231, 0.35); */
}

.request-card {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.request-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15.6px;
}

.request-card small {
  color: var(--muted);
  flex: 0 0 auto;
}

.request-name-link {
  color: var(--primary);
  cursor: pointer;
}

.request-space-name {
  color: var(--primary);
}

.request-actions {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* History rows have a single action button. */
.request-actions:has(> :only-child) {
  grid-template-columns: 1fr 1fr;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  margin-top: 30px;
}

.error-state {
  color: var(--danger);
}

.form-error {
  color: var(--danger);
  font-size: 15.6px;
  margin: 0 0 10px;
}

.is-hidden {
  display: none !important;
}

.field {
  display: block;
  font-size: 15.6px;
  color: var(--muted);
  margin-bottom: 12px;
}

.date-dropdowns {
  display: flex;
  gap: 8px;
}

.date-dropdowns select {
  flex: 1;
  min-width: 0;
}

input,
select,
textarea {
  margin-top: 6px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 16.8px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
}

input::placeholder,
textarea::placeholder {
  color: #aeb3c6;
  opacity: 1;
}

.advanced-settings,
.additional-fields {
  margin-bottom: 12px;
}
.advanced-settings > summary,
.additional-fields > summary {
  font-size: 15.6px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  list-style: none;
  padding: 6px 0;
}

.advanced-settings > summary::-webkit-details-marker,
.additional-fields > summary::-webkit-details-marker {
  display: none;
}

.advanced-settings > summary::before,
.additional-fields > summary::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  vertical-align: -2px;
  background-color: var(--primary);
  -webkit-mask: url("./resources/icons/arrow_right.svg") no-repeat center / contain;
  mask: url("./resources/icons/arrow_right.svg") no-repeat center / contain;
}

.advanced-settings[open] > summary::before,
.additional-fields[open] > summary::before {
  -webkit-mask-image: url("./resources/icons/arrow_down.svg");
  mask-image: url("./resources/icons/arrow_down.svg");
}

.advanced-settings .checkbox-field,
.additional-fields .checkbox-field {
  margin-top: 8px;
  margin-bottom: 0;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 15.6px;
  color: var(--text);
  padding: 12px 0 12px;
  cursor: pointer;
}

.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  flex: 0 0 auto;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-field span {
  line-height: 1.4;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.stepper span {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 14.4px;
}

.stepper .active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.row-gap {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.review-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
}

.review-card p {
  margin-bottom: 10px;
}

.space-type-panel {
  display: none;
}

.space-type-panel.active {
  display: block;
}

.success-view {
  text-align: center;
  padding-top: 30px;
}

.success-icon {
  width: 86px;
  height: 86px;
  margin: 0 auto 14px;
  border-radius: 20px;
}

.bottom-nav {
  background: var(--bg);
  /* position: fixed; */
  left: 50%;
  /* transform: translateX(-50%); */
  bottom: 0;
  width: min(430px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--primary-soft);
}

.nav-btn {
  border: 0;
  background: transparent;
  padding: 10px 8px;
  color: var(--muted);
  font-size: 14.4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.nav-btn.active {
  color: var(--primary-soft);
  background: var(--primary);
}

.nav-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-badge,
.segment-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--bg);
}

.segment-badge {
  position: static;
  top: auto;
  right: auto;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  font-size: 10px;
  padding: 0 4px;
  margin-left: 6px;
  box-shadow: none;
}

.requests-tabs .segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}

.load-more-wrap .secondary-btn.small {
  width: auto;
  min-width: 140px;
  margin: 0;
}

.archive-toggle-wrap {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

.archive-toggle-wrap .text-link-btn {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 4px 8px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.archive-toggle-wrap .text-link-btn h5 {
  margin: 0;
  color: inherit;
  font-size: 14.4px;
  font-weight: 600;
}

.text-link-btn {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
}

.detail-url-link {
  color: var(--primary);
  text-decoration: underline;
  word-break: break-all;

  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.text-link-btn.right {
  float: right;
  padding: 4px;
}

#events-list {
  overflow-y: auto;
  min-height: 0;
}

#events-segment-events.active,
#events-segment-local-events.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.scroll-list {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  padding: 0 14px;
}

.scroll-list-small {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 180px;
}

.scroll-list-small::after {
  content: "";
  position: sticky;
  bottom: -10px;

  display: block;
  width: 50px;
  height: 50px;
  margin: 0 auto;

  background: url("./resources/icons/arrow_down.svg") center/contain no-repeat;
  filter: brightness(0) saturate(100%) invert(36%) sepia(72%) saturate(2450%) hue-rotate(228deg) brightness(96%) contrast(92%);
  pointer-events: none;

  animation: bounce 1.5s infinite;
}

.scroll-list-small.scroll-hint-hidden::after {
  display: none;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(6px);
  }
}

.filler {
  height: 50px;
  flex-shrink: 0;
}

.local-events-location-picker {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  min-height: 240px;
}

.local-events-location-hint {
  color: var(--muted);
  text-align: center;
  margin: 0 0 16px;
}

/* City autocomplete */
.city-field {
  position: relative;
}

.city-suggestions {
  position: absolute;
  z-index: 50;
  left: 0;
  right: 0;
  top: 100%;
  color: var(--primary);
  background: var(--bg);
  border: 1px solid #ddd;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.city-suggestion {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.city-suggestion:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.city-suggestion.muted {
  color: #777;
  cursor: default;
}

.line-separator {
  padding: 10px 0 0 0;
}

.collapsed {
  position: relative;
  max-height: 80px;
  overflow: hidden;
}

.collapsed::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30px;
  background: linear-gradient(
    transparent,
    var(--bg)
  );
}

.event-show-description-wrapper {
  display: flex;
  justify-content: center;
}

.pointer {
  cursor: pointer;
}

a:-webkit-any-link {
  color: var(--primary);
}