:root {
  --spaces-pad-1: 0.75rem;
  --spaces-pad-2: 1rem;
  --spaces-gap-1: 0.5rem;
  --spaces-gap-2: 0.75rem;
  --spaces-font-sm: 0.8125rem;
  --spaces-font-md: 0.875rem;
  --spaces-font-lg: 0.9375rem;
  --spaces-icon-size: 1.25rem;
  --spaces-badge-height: 1.125rem;
  --spaces-badge-min: 1.125rem;
}

/* =========================================
   SPACE FEED LAYOUT
   ========================================= */

.spaces-root {
  max-width: 720px;
  margin: 0 auto;
}

.space-hero-header {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

#space-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-bottom: 80px;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
}

.space-state {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
}

.space-state-action {
  margin-top: 12px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.space-post-snapshot {
  cursor: default;
}

.space-post-author {
  cursor: pointer;
}

.space-post-snapshot-title {
  margin: 0 0 8px 0;
}

.space-post-snapshot-link {
  color: inherit;
  text-decoration: none;
}

.space-post-snapshot-link:hover {
  text-decoration: underline;
}

.space-post-snapshot-desc {
  margin: 0 0 12px 0;
}

.space-post-snapshot-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.space-post-snapshot-metrics {
  display: flex;
  align-items: center;
  gap: 6px;
}

.space-post-snapshot-cta {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.space-post-snapshot-cta:hover {
  background: var(--bg);
}

#view-space.spaces-root #space-feed>.post {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 14px 26px 0;
  transition: background-color 60ms linear;
  position: relative;
}

#view-space.spaces-root #space-feed>.post::after {
  content: '';
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: 0;
  height: 1px;
  background: #E5E7EB;
}

#view-space.spaces-root #space-feed>.post:last-child::after {
  display: none;
}

#view-space.spaces-root #space-feed>.post:hover {
  background: #F4F6F8;
  box-shadow: none;
}

#view-space.spaces-root #space-feed>.post .p-head {
  margin-bottom: 8px;
}

#view-space.spaces-root #space-feed>.post .p-user {
  gap: 7px;
  align-items: center;
}

#view-space.spaces-root #space-feed>.post .avatar {
  width: 26px;
  height: 26px;
}

#view-space.spaces-root #space-feed>.post .who {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  flex-wrap: wrap;
  line-height: 1.2;
}

#view-space.spaces-root #space-feed>.post .who .name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  color: #0F1A1C;
}

#view-space.spaces-root #space-feed>.post .meta-line {
  font-size: 12px;
  font-weight: 400;
  gap: 5px;
  margin-top: 0;
  color: #576F76;
  line-height: 1.2;
}

#view-space.spaces-root #space-feed>.post .title {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: 0;
  color: #101214;
  margin: 0 0 8px 0 !important;
}

#view-space.spaces-root #space-feed>.post .desc {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14.5px;
  font-weight: 400;
  line-height: 1.48;
  color: #1f2933;
  margin: 0 0 12px 0 !important;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#view-space.spaces-root #space-feed>.post[data-has-media="true"] .desc {
  display: none;
}

#view-space.spaces-root #space-feed>.post .post-foot {
  border-top: 0;
  border-radius: 0;
  justify-content: flex-start !important;
  gap: 12px;
  margin-top: 14px;
  margin-bottom: 0;
  margin-left: -26px;
  margin-right: -26px;
  padding: 4px 26px 14px;
}

#view-space.spaces-root #space-feed>.post .posts-card-actions {
  margin-left: 0;
}

#view-space.spaces-root #space-feed>.post .posts-card-actions--full {
  gap: 0;
}

#view-space.spaces-root #space-feed>.post .like-btn,
#view-space.spaces-root #space-feed>.post .view-btn,
#view-space.spaces-root #space-feed>.post .posts-share-btn {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #EEF2F5;
  color: #0F1A1C;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  transition: background-color 0.14s ease, color 0.14s ease;
}

#view-space.spaces-root #space-feed>.post .like-btn:hover,
#view-space.spaces-root #space-feed>.post .posts-share-btn:hover {
  background: #E2E8F0;
  color: #0F172A;
}

#view-space.spaces-root #space-feed>.post .like-btn:hover {
  background: #FEECEF;
  color: #E11D48;
}

#view-space.spaces-root #space-feed>.post .like-btn.active {
  background: #EEF2F5;
  color: #E11D48;
}

#view-space.spaces-root #space-feed>.post .like-btn.active:hover {
  background: #FEECEF;
  color: #E11D48;
}

#view-space.spaces-root #space-feed>.post .posts-meta-chip,
#view-space.spaces-root #space-feed>.post .posts-recommendation-chip {
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
}

#view-space.spaces-root #space-feed>.post .posts-recommendation-chip {
  background: rgba(37, 99, 235, 0.06);
  border-color: rgba(37, 99, 235, 0.12);
}

.spaces-sidebar-widget {
  background: #FBFCFE;
  border: 1px solid #E8EDF3;
  border-radius: 16px;
  padding: var(--spaces-pad-2);
  margin-bottom: var(--spaces-pad-2);
  box-shadow: none;
}

.spaces-sidebar-title {
  font-size: var(--spaces-font-lg);
  font-weight: 600;
  color: var(--text);
  margin: 0 0 var(--spaces-gap-2) 0;
}

.spaces-list {
  display: flex;
  flex-direction: column;
  gap: var(--spaces-gap-1);
}

.spaces-item {
  display: flex;
  align-items: center;
  gap: var(--spaces-gap-2);
  padding: var(--spaces-gap-1);
  border-radius: calc(var(--radius) - var(--spaces-gap-1));
  cursor: pointer;
  transition: background 0.2s ease;
}

.spaces-item:hover {
  background: #F1F5F9;
}

.spaces-icon {
  font-size: var(--spaces-icon-size);
  line-height: 1;
}

.spaces-info {
  flex: 1;
  min-width: 0;
}

.spaces-title {
  font-size: var(--spaces-font-md);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.spaces-activity {
  font-size: 0.75rem;
  /* 12px */
  color: var(--muted);
  opacity: 0.9;
  white-space: nowrap;
  margin-top: 2px;
}

.spaces-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: #22C55E;
  /* Lighter Green */
  color: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 5px rgba(34, 197, 94, 0.25);
  margin-left: 8px;
}

.spaces-chevron {
  width: var(--spaces-icon-size);
  height: var(--spaces-icon-size);
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spaces-empty {
  padding: var(--spaces-pad-1);
  font-size: var(--spaces-font-sm);
  color: var(--muted);
  text-align: center;
}

/* =========================
   MOBILE HORIZONTAL SPACES BAR
   ========================= */
.mobile-spaces-bar {
  display: none;
}

@media (max-width: 720px) {
  .spaces-root {
    max-width: 100%;
  }

  #space-feed {
    gap: 0;
  }

  #view-space.spaces-root #space-feed>.post {
    padding: 16px 16px 0;
    border-radius: 0;
  }

  #view-space.spaces-root #space-feed>.post::after {
    left: 16px;
    right: 16px;
  }

  #view-space.spaces-root #space-feed>.post .p-head {
    margin-bottom: 7px;
  }

  #view-space.spaces-root #space-feed>.post .p-user {
    gap: 7px;
    align-items: flex-start;
  }

  #view-space.spaces-root #space-feed>.post .who {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 2px;
  }

  #view-space.spaces-root #space-feed>.post .who .name {
    font-size: 12px;
  }

  #view-space.spaces-root #space-feed>.post .meta-line {
    font-size: 12px;
    line-height: 1.4;
  }

  #view-space.spaces-root #space-feed>.post .title {
    font-size: 16.5px;
    font-weight: 600;
    line-height: 1.32;
  }

  #view-space.spaces-root #space-feed>.post .desc {
    font-size: 14.5px;
    line-height: 1.48;
    -webkit-line-clamp: 2;
  }

  #view-space.spaces-root #space-feed>.post .post-foot {
    gap: 8px;
    margin-left: -16px;
    margin-right: -16px;
    padding: 4px 16px 12px;
  }

  .mobile-spaces-bar {
    /* Display controlled by global layout rules in static/css/style.css */
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 0 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-spaces-bar::-webkit-scrollbar {
    display: none;
  }

  .mobile-spaces-list {
    display: flex;
    gap: 10px;
    padding: 0 12px;
    min-width: min-content;
  }

  .mobile-space-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    flex-shrink: 0;
    min-width: 52px;
  }

  .mobile-space-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #F1F5F9 0%, #E2E8F0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
  }

  .mobile-space-chip:active .mobile-space-icon {
    transform: scale(0.95);
  }

  .mobile-space-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.1;
  }

  .mobile-space-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: #22C55E;
    color: #FFFFFF;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(34, 197, 94, 0.3);
  }

  .mobile-space-icon-wrapper {
    position: relative;
  }

  /* Hide spaces bar on mobile when inside a space (saves vertical space) */
  body.view-space .mobile-spaces-bar {
    display: none !important;
  }
}

/* =========================================
   SPACE HERO & TOOLBAR (Matching Platform UI)
   ========================================= */

.space-hero-header {
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

@media (min-width: 768px) {
  .space-hero-header {
    padding: 18px 0 8px;
    margin-bottom: 6px;
  }
}

.space-hero-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

@media (min-width: 768px) {
  .space-hero-top {
    margin-bottom: 16px;
  }
}

.space-hero-icon {
  font-size: 24px;
  width: 48px;
  height: 48px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  overflow: hidden;
}

.space-hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.space-hero-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}

.space-hero-desc {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}


/* Base Toolbar: search above, filter row below */
.space-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.space-search-wrapper {
  position: relative;
  width: 100%;
  min-width: 0;
}

/* Filter row: time + city + attribute filters in a single scrollable row */
.space-filter-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;          /* Firefox */
  padding-bottom: 2px;            /* Room for focus rings */
}

.space-filter-row::-webkit-scrollbar {
  display: none;
}

.space-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  z-index: 2;
  pointer-events: none;
  display: inline-flex;
}

.space-search-input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.space-search-input:focus {
  border-color: var(--brand-dark, #0F172A);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.05);
}

.space-time-dropdown-wrapper,
.space-city-filter-wrapper,
.space-attribute-filter-wrapper {
  position: relative;
  flex-shrink: 0;
  width: 120px;   /* compact default — fits 3+ filters on most phones */
}

@media (min-width: 480px) {
  .space-time-dropdown-wrapper,
  .space-city-filter-wrapper,
  .space-attribute-filter-wrapper {
    width: 140px;
  }
}

@media (min-width: 768px) {
  .space-time-dropdown-wrapper {
    width: 180px;
  }

  .space-city-filter-wrapper,
  .space-attribute-filter-wrapper {
    width: 150px;
  }
}

.space-time-dropdown,
.space-city-filter,
.space-attribute-filter {
  width: 100%;
  height: 40px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  text-overflow: ellipsis;
}

.space-time-dropdown:focus,
.space-city-filter:focus,
.space-attribute-filter:focus {
  border-color: var(--brand-dark, #0F172A);
}

.space-time-dropdown:hover,
.space-city-filter:hover,
.space-attribute-filter:hover {
  background-color: #F8FAFC;
  border-color: #CBD5E1;
}

/* Final Spaces view overrides: keep the route aligned with Feed's open stream. */
body.view-space #view-space.spaces-root {
  max-width: 720px;
  margin: 0 auto;
}

body.view-space #view-space.spaces-root .space-hero-header {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding-bottom: 6px;
  margin-bottom: 2px;
}

body.view-space #view-space.spaces-root .space-search-input {
  min-height: 52px;
  height: 52px;
  border-radius: 16px;
  box-shadow: none;
}

body.view-space #view-space.spaces-root .space-time-dropdown,
body.view-space #view-space.spaces-root .space-city-filter,
body.view-space #view-space.spaces-root .space-attribute-filter {
  min-height: 52px;
  height: 52px;
  border-radius: 16px;
  box-shadow: none;
}

@media (max-width: 720px) {
  body.view-space #view-space.spaces-root {
    max-width: 100%;
  }

  body.view-space #view-space.spaces-root .space-search-input,
  body.view-space #view-space.spaces-root .space-time-dropdown,
  body.view-space #view-space.spaces-root .space-city-filter,
  body.view-space #view-space.spaces-root .space-attribute-filter {
    min-height: 50px;
    height: 50px;
    border-radius: 14px;
  }

  /* Filter row scrolls horizontally — no wrapping, no overflow on mobile */
  .space-filter-row {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
  }

  .space-time-dropdown-wrapper,
  .space-city-filter-wrapper,
  .space-attribute-filter-wrapper {
    flex-shrink: 0;
    width: 120px;
  }
}

/* Match the refined feed card rhythm for space posts only. */
#view-space.spaces-root #space-feed>.post .title {
  margin-bottom: 6px !important;
}

#view-space.spaces-root #space-feed>.post .posts-card-desc-preview {
  display: -webkit-box !important;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 8px 0 !important;
  color: #334155;
  font-size: 14.5px;
  line-height: 1.4;
  white-space: normal;
}

#view-space.spaces-root #space-feed>.post .post-foot {
  margin-top: 8px !important;
  padding-top: 2px !important;
}

#view-space.spaces-root #space-feed>.post:hover {
  background: #F8FAFC !important;
  box-shadow: none !important;
}

#view-space.spaces-root #space-feed>.post:hover .like-btn,
#view-space.spaces-root #space-feed>.post:hover .view-btn,
#view-space.spaces-root #space-feed>.post:hover .posts-share-btn {
  background: #EEF2F5;
  box-shadow: none;
}

#view-space.spaces-root #space-feed>.post .view-btn:hover,
#view-space.spaces-root #space-feed>.post .posts-share-btn:hover {
  background: #E2E8F0 !important;
  color: #0F172A;
}

@media (max-width: 900px) {
  #view-space.spaces-root #space-feed>.post .title {
    margin-bottom: 5px !important;
  }

  #view-space.spaces-root #space-feed>.post .posts-card-desc-preview {
    -webkit-line-clamp: 2;
    margin-bottom: 6px !important;
    font-size: 14px;
  }

  #view-space.spaces-root #space-feed>.post .post-foot {
    margin-top: 6px !important;
    padding-top: 2px !important;
  }
}

/* Canonical post card visual parity with Home feed. Keep space-specific content intact. */
#view-space.spaces-root #space-feed>.post {
  transition: background-color 60ms linear;
}

#view-space.spaces-root #space-feed>.post .title {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: 0;
  color: #101214;
  margin: 0 0 6px 0 !important;
}

#view-space.spaces-root #space-feed>.post .posts-card-desc-preview {
  display: -webkit-box !important;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 10px 0 !important;
  color: #0F1A1C;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.42;
  white-space: normal;
}

#view-space.spaces-root #space-feed>.post .post-foot {
  margin-top: 8px !important;
  padding-top: 2px !important;
}

#view-space.spaces-root #space-feed>.post:hover {
  background: #F8FAFC !important;
  box-shadow: none !important;
}

#view-space.spaces-root #space-feed>.post:hover .like-btn,
#view-space.spaces-root #space-feed>.post:hover .view-btn,
#view-space.spaces-root #space-feed>.post:hover .posts-share-btn {
  background: #EEF2F5;
  box-shadow: none;
}

#view-space.spaces-root #space-feed>.post .like-btn,
#view-space.spaces-root #space-feed>.post .view-btn,
#view-space.spaces-root #space-feed>.post .posts-share-btn {
  background: #EEF2F5;
  box-shadow: none;
  transition: background-color 60ms linear, color 60ms linear;
}

#view-space.spaces-root #space-feed>.post .view-btn:hover,
#view-space.spaces-root #space-feed>.post .posts-share-btn:hover {
  background: #E2E8F0 !important;
  color: #0F172A;
}

@media (max-width: 900px) {
  #view-space.spaces-root #space-feed>.post .p-head {
    margin-bottom: 7px;
    padding-right: 44px;
    box-sizing: border-box;
  }

  #view-space.spaces-root #space-feed>.post .p-user {
    gap: 7px;
    align-items: flex-start;
    max-width: 100%;
  }

  #view-space.spaces-root #space-feed>.post .who {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 2px;
    max-width: 100%;
  }

  #view-space.spaces-root #space-feed>.post .name-row {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  #view-space.spaces-root #space-feed>.post .mobile-meta-handle,
  #view-space.spaces-root #space-feed>.post .mobile-meta-dot,
  #view-space.spaces-root #space-feed>.post .mobile-meta-time {
    display: inline-flex;
  }

  #view-space.spaces-root #space-feed>.post .mobile-meta-handle {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #view-space.spaces-root #space-feed>.post .meta-line {
    font-size: 12px;
    line-height: 1.4;
    max-width: 100%;
  }

  #view-space.spaces-root #space-feed>.post .meta-line .handle-text,
  #view-space.spaces-root #space-feed>.post .meta-line .handle-text+.meta-sep,
  #view-space.spaces-root #space-feed>.post .meta-line .meta-time,
  #view-space.spaces-root #space-feed>.post .meta-line .meta-time+.meta-sep {
    display: none;
  }

  #view-space.spaces-root #space-feed>.post .title {
    font-size: 16.5px;
    font-weight: 600;
    line-height: 1.32;
    margin-bottom: 5px !important;
  }

  #view-space.spaces-root #space-feed>.post .posts-card-desc-preview {
    -webkit-line-clamp: 2;
    margin-bottom: 8px !important;
    font-size: 13px;
    line-height: 1.42;
  }

  #view-space.spaces-root #space-feed>.post .post-foot {
    margin-top: 6px !important;
    padding-top: 2px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   Search: clear (×) button inside search input
   ═══════════════════════════════════════════════════════════════════════ */

/* Hidden by default — JS adds .space-search-clear-btn--active to show it.
   We use a class (not the hidden attr) because display:flex would otherwise
   override [hidden]'s display:none. */
.space-search-clear-btn {
  display: none;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--muted, #64748B);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
  z-index: 3;
  transition: background 0.15s ease, color 0.15s ease;
}

.space-search-clear-btn.space-search-clear-btn--active {
  display: flex;
}

.space-search-clear-btn:hover {
  background: #EEF2F5;
  color: #0F172A;
}

/* Give the input text room when the X is visible */
.space-search-wrapper:has(.space-search-clear-btn--active) .space-search-input {
  padding-right: 42px;
}

/* ═══════════════════════════════════════════════════════════════════════
   Suggestions dropdown
   ═══════════════════════════════════════════════════════════════════════ */

.space-suggestions-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.13);
  z-index: 200;
  overflow: hidden;
  padding: 4px 0;
}

.space-suggestion-item {
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--text, #1E293B);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.1s ease;
}

.space-suggestion-item:hover,
.space-suggestion-item--active {
  background: #F1F5F9;
  color: #0F172A;
}

/* ═══════════════════════════════════════════════════════════════════════
   Filter pills — custom button + dropdown panel
   Click button → panel opens. Pick option → applies. Pick default → resets.
   ═══════════════════════════════════════════════════════════════════════ */

.space-filter-pill {
  position: relative;
  flex-shrink: 0;
}

/* The clickable filter button */
.space-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 40px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 10px;
  background: var(--surface, #fff);
  color: var(--text, #1E293B);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.space-filter-btn:hover {
  border-color: #CBD5E1;
  background: #F8FAFC;
}

/* Active: a non-default value is applied — darker border, bolder label */
.space-filter-btn--active {
  border-color: #1E293B;
  border-width: 1.5px;
  font-weight: 600;
  color: #0F172A;
}

.space-filter-btn--active:hover {
  border-color: #0F172A;
  background: #F8FAFC;
}

/* Chevron rotates when the panel is open */
.space-filter-chevron {
  color: #64748B;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.space-filter-btn[aria-expanded="true"] .space-filter-chevron {
  transform: rotate(180deg);
}

.space-filter-btn--active .space-filter-chevron {
  color: #334155;
}

/* Dropdown panel */
.space-filter-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: max(100%, 150px);
  background: var(--surface, #fff);
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  z-index: 150;
  overflow: hidden;
  padding: 4px 0;
}

/* Option rows */
.space-filter-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text, #1E293B);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.1s ease;
  gap: 12px;
}

.space-filter-option:hover {
  background: #F1F5F9;
  color: #0F172A;
}

/* Selected option: bold + checkmark */
.space-filter-option--selected {
  font-weight: 600;
  color: #0F172A;
}

.space-filter-option--selected::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23334155' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   Result count label  ("32 results for 'cashier'")
   ═══════════════════════════════════════════════════════════════════════ */

.space-result-count {
  font-size: 13px;
  color: #64748B;
  font-weight: 400;
  padding: 4px 0 0 2px;
  display: block;
}

/* view-space context tweaks for the taller 52px inputs */
body.view-space #view-space.spaces-root .space-search-clear-btn {
  width: 34px;
  height: 34px;
  right: 12px;
}

body.view-space #view-space.spaces-root .space-suggestions-dropdown {
  top: calc(100% + 6px);
  border-radius: 14px;
}

/* view-space filter btn: match the 52px input height and 16px border-radius */
body.view-space #view-space.spaces-root .space-filter-btn {
  height: 52px;
  border-radius: 16px;
  font-size: 13.5px;
  padding: 0 12px 0 14px;
}

@media (max-width: 720px) {
  body.view-space #view-space.spaces-root .space-filter-btn {
    height: 50px;
    border-radius: 14px;
  }
}
