:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a1f2e;
  --muted: #5c6578;
  --border: #dde3ea;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --success: #059669;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --layout-max-width: 1440px;
  --directory-overlay-inset: 16px;
  --directory-overlay-edge: 30px;
  --profile-photo-zoom-width: 220px;
  --profile-photo-zoom-height: 280px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  overscroll-behavior: none;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.5;
  touch-action: manipulation;
  overscroll-behavior: none;
  overflow-x: clip;
}

.app-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: var(--bg);
  background-image: url("/data/background/background.jpg");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform;
}

body > :not(.app-background):not(.modal-backdrop):not(.feedback-reply-notice-wrap):not(.toast) {
  position: relative;
  z-index: 1;
}

#app-shell {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
}

#app-shell::before {
  content: "";
  position: absolute;
  top: calc(-1 * var(--directory-overlay-edge));
  bottom: calc(-1 * var(--directory-overlay-edge));
  left: 50%;
  transform: translateX(-50%);
  width: min(
    calc(var(--layout-max-width) + (2 * var(--directory-overlay-edge))),
    calc(100% - 2rem + (2 * var(--directory-overlay-inset)) + (2 * var(--directory-overlay-edge)))
  );
  box-sizing: border-box;
  border-radius: 0;
  pointer-events: none;
  z-index: 0;
  background: rgba(244, 246, 248, 0.72);
}

#app-shell > header,
#app-shell > .service-status,
#app-shell > main,
#app-shell > .directory-end-actions {
  position: relative;
  z-index: 1;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  width: min(var(--layout-max-width), calc(100% - 2rem));
  margin: 0 auto;
}

.site-header {
  padding: 2rem 0 1.25rem;
}

.site-header h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.02em;
}

.site-header p {
  margin: 0;
  color: var(--muted);
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filters {
  padding: 1rem;
  margin-bottom: 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  align-items: end;
}

.filters-wrap {
  margin-bottom: 1.25rem;
}

.filters-toggle {
  display: inline-flex;
}

.filters-toggle.is-active {
  border-color: #bfdbfe;
  background: var(--accent-soft);
  color: var(--accent);
}

.filters-wrap:not(.is-open) .filters {
  display: none;
}

.filters-wrap.is-open .filters {
  display: grid;
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--accent);
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.field-wide {
  grid-column: 1 / -1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.88rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #f8fafc;
}

.btn-danger {
  background: #fff;
  border-color: #fecaca;
  color: var(--danger);
}

.btn-danger:hover {
  background: #fef2f2;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.stats-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.stats-bar strong {
  color: var(--text);
}

.residents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  padding-bottom: 2.5rem;
  align-items: start;
}

.resident-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.resident-card-top {
  display: grid;
  gap: 0.65rem;
  align-items: start;
  margin-bottom: 0.65rem;
}

.resident-card-grid-photos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  width: 100%;
  height: 8.5rem;
}

.resident-card-grid-photos--1 {
  grid-template-columns: minmax(0, 1fr);
  justify-content: center;
}

.resident-card-grid-photos--1 .resident-card-grid-photo {
  width: 50%;
  justify-self: center;
}

.resident-card-grid-photo {
  position: relative;
  display: block;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 0.65rem;
}

.resident-card-grid-photo .avatar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.resident-card-grid-photo .avatar--grid {
  min-height: 0;
}

.resident-card-grid-photo .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.resident-card-photo-mood {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  display: grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 50%;
  background: var(--surface);
  font-size: 1rem;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.resident-card-head {
  min-width: 0;
}

.resident-card-name {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  min-height: 2.5em;
}

.resident-card-badges {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.2rem;
  pointer-events: none;
}

.resident-card-badge {
  font-size: 1.35rem;
  line-height: 1;
}

.social-mood-options {
  display: grid;
  gap: 0.35rem;
}

.social-mood-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.35rem;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  user-select: none;
}

.social-mood-option input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.social-mood-option:has(input:checked) {
  border-color: var(--accent);
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.social-mood-option:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.social-mood-option:has(input:checked):hover {
  border-color: var(--accent);
  background: #dbeafe;
}

.social-mood-option:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.social-mood-option-emoji {
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
}

.social-mood-option-text {
  font-size: 0.86rem;
  line-height: 1.25;
}

.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.avatar {
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #eef2f7;
  border: 1px solid var(--border);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar--sm {
  width: 44px;
  height: 44px;
}

.avatar--md {
  width: 56px;
  height: 56px;
}

.avatar--empty,
.profile-photo--empty {
  background:
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  position: relative;
}

.avatar--empty::before,
.profile-photo--empty::before {
  content: "?";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #94a3b8;
  line-height: 1;
  pointer-events: none;
}

.avatar--empty::after,
.profile-photo--empty::after {
  content: none;
}

.avatar--sm.avatar--empty::before {
  font-size: 1.35rem;
}

.avatar--md.avatar--empty::before {
  font-size: 1.65rem;
}

.profile-photo--empty::before {
  font-size: 2.75rem;
}

.profile-photo--xs.profile-photo--empty::before {
  font-size: 1.75rem;
}

.photo-editor .profile-photo--empty::before {
  font-size: 2.1rem;
}

.profile-photo {
  width: 120px;
  height: 120px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #eef2f7;
  flex-shrink: 0;
}

.profile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-photo--loading {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef2f7;
}

.profile-photo--loading::after {
  content: "";
  width: 24px;
  height: 24px;
  border: 2px solid #cbd5e1;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: photo-preview-spin 0.7s linear infinite;
}

@keyframes photo-preview-spin {
  to {
    transform: rotate(360deg);
  }
}

.photo-editor {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.photo-editor .profile-photo {
  width: 88px;
  height: 88px;
}

.admin-photo-cell {
  width: 52px;
}

.family-list {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.family-row {
  display: grid;
  grid-template-columns: 88px repeat(5, minmax(0, 1fr)) auto;
  gap: 0.65rem;
  align-items: end;
  padding: 0.75rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #fbfdff;
}

.family-row-about {
  grid-column: 2 / -2;
  align-self: start;
}

.family-row-photo {
  display: grid;
  gap: 0.35rem;
  justify-items: center;
}

.family-photo-btn {
  width: 100%;
  justify-content: center;
  font-size: 0.82rem;
  padding: 0.35rem 0.5rem;
}

.btn-compact {
  min-height: auto;
}

.profile-photo--xs {
  width: 64px;
  height: 64px;
  border-radius: 12px;
}

.profile-photo--xs.avatar,
.profile-photo--xs .avatar {
  width: 64px;
  height: 64px;
}

.detail-family-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.detail-family-head .detail-family-name {
  margin-bottom: 0;
}

.photo-zoom {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  cursor: zoom-in;
}

.photo-zoom:focus {
  outline: none;
}

.photo-zoom:focus-visible .avatar {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.photo-zoom-popover {
  position: absolute;
  right: calc(100% + 0.75rem);
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 30;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.photo-zoom:hover .photo-zoom-popover,
.photo-zoom:focus-within .photo-zoom-popover,
.photo-zoom.is-open .photo-zoom-popover {
  opacity: 1;
  visibility: visible;
}

.photo-zoom.is-open .photo-zoom-popover {
  pointer-events: auto;
}

.photo-zoom-popover .profile-photo--zoom {
  width: var(--profile-photo-zoom-width);
  height: var(--profile-photo-zoom-height);
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
}

.photo-zoom--grid .photo-zoom-popover {
  left: calc(100% + 0.75rem);
  right: auto;
  top: 50%;
  transform: translateY(-50%);
}

.resident-card:has(.photo-zoom:hover) {
  position: relative;
  z-index: 25;
}

@media (max-width: 720px) {
  .photo-zoom--grid {
    pointer-events: none;
    cursor: inherit;
  }

  .photo-zoom--grid .photo-zoom-popover,
  .photo-zoom--grid:hover .photo-zoom-popover,
  .photo-zoom--grid:focus-within .photo-zoom-popover,
  .photo-zoom--grid.is-open .photo-zoom-popover {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
  }

  .photo-zoom--grid.is-open::before {
    content: none;
    display: none;
  }

  .resident-card:has(.photo-zoom--grid:hover) {
    z-index: auto;
  }
}

@media (min-width: 561px) {
  .photo-zoom--family:focus-within .photo-zoom-popover,
  .photo-zoom--family.is-open .photo-zoom-popover {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .photo-zoom--family:hover .photo-zoom-popover {
    opacity: 1;
    visibility: visible;
  }
}

@media (max-width: 560px) {
  .photo-zoom:not(.photo-zoom--grid) .photo-zoom-popover {
    position: fixed;
    left: 50%;
    top: 50%;
    right: auto;
    transform: translate(-50%, -50%);
  }

  .photo-zoom:not(.photo-zoom--grid).is-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 25;
  }
}

.cars-list {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.car-row {
  display: grid;
  grid-template-columns: minmax(0, 220px) auto;
  gap: 0.65rem;
  align-items: end;
  padding: 0.75rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #fbfdff;
}

@media (max-width: 720px) {
  .family-row {
    grid-template-columns: 1fr;
  }

  .family-row-about {
    grid-column: 1;
  }

  .family-row-photo {
    grid-template-columns: 64px 1fr auto;
    align-items: center;
    justify-items: start;
  }

  .car-row {
    grid-template-columns: 1fr auto;
  }
}

.family-row .family-remove {
  min-width: 36px;
  padding-inline: 0.5rem;
  margin-bottom: 0.1rem;
}

.detail-family-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-family-item {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.detail-family-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.detail-family-name {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.detail-family-line {
  font-size: 0.92rem;
  margin-top: 0.2rem;
}

.detail-family-label {
  display: inline-block;
  min-width: 4.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.chip-link--inline {
  display: inline-flex;
  padding: 0.2rem 0.55rem;
  font-size: 0.88rem;
}

.resident-card:hover {
  transform: translateY(-2px);
  border-color: #bfd3ff;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.12);
}

.apartment-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  max-width: 100%;
}

.resident-card-apartment {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  align-self: stretch;
  box-sizing: border-box;
  margin-bottom: 0.65rem;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  font-size: 0.88rem;
  white-space: normal;
  line-height: 1.35;
  text-align: center;
}

.resident-card-details,
.resident-card-contacts {
  display: grid;
  gap: 0.3rem;
}

.resident-card-details {
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}

.resident-card-contacts {
  margin-top: 0.75rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}

.resident-card-field {
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.resident-card-field--profession {
  -webkit-line-clamp: 2;
  min-height: 2.7em;
}

.resident-card-field--family,
.resident-card-field--phone,
.resident-card-field--telegram {
  -webkit-line-clamp: 1;
  min-height: 1.35em;
}

.resident-card-field--phone,
.resident-card-field--telegram {
  font-size: 0.84rem;
}

@media (max-width: 1279px) {
  #app-shell::before {
    width: 100%;
    left: 0;
    transform: none;
  }

  .container {
    width: auto;
    max-width: none;
    margin-inline: max(1rem, env(safe-area-inset-left, 0px)) max(1rem, env(safe-area-inset-right, 0px));
  }

  .filters-wrap {
    margin-bottom: 1rem;
  }

  .filters-toggle {
    width: 100%;
  }

  .directory-end-actions-row {
    display: flex;
    justify-content: center;
    padding-right: 0;
  }

  .resident-card-name {
    font-size: 1.2rem;
  }
}

@media (max-width: 720px) and (orientation: portrait) {
  .residents-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .resident-card-name {
    font-size: 1.28rem;
  }
}

@media (max-width: 1279px) and (orientation: landscape) {
  .residents-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .residents-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1.125rem;
  }

  .resident-card {
    padding: 1.15rem;
  }

  .resident-card-top {
    gap: 0.875rem;
    margin-bottom: 0.75rem;
  }

  .resident-card-grid-photos {
    gap: 0.45rem;
    height: 9.25rem;
  }

  .resident-card-name {
    font-size: 1.1rem;
  }

  .resident-card-apartment {
    font-size: 0.92rem;
    padding: 0.5rem 0.85rem;
  }

  .resident-card-field {
    font-size: 0.88rem;
  }
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.service-status {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #fcd34d;
  background: #fef3c7;
  color: #92400e;
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.45;
}

.service-status.is-error {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.service-status.hidden {
  display: none;
}

.access-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: transparent;
}

.access-gate.hidden {
  display: none;
}

.access-card {
  width: min(460px, 100%);
  padding: 1.5rem;
}

.access-card h2 {
  margin: 0 0 0.5rem;
}

.access-lead {
  margin: 0 0 1rem;
  color: var(--muted);
}

.access-message {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.access-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.access-telegram-slot {
  display: flex;
  justify-content: center;
  min-height: 48px;
  margin: 1rem 0 0.5rem;
}

.access-telegram-pending {
  margin: 0;
  text-align: center;
  color: var(--accent, #2563eb);
  font-weight: 600;
}

.profile-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 1.25rem 1.25rem;
}

.profile-picker-item {
  width: 100%;
  text-align: left;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 0.75rem;
  background: var(--surface, #fff);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.profile-picker-item:hover,
.profile-picker-item:focus-visible {
  border-color: var(--accent, #2563eb);
  outline: none;
}

.invite-new-profile {
  width: 100%;
  margin-top: 0.85rem;
}

.profile-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 0;
  padding: 0 0 0.25rem;
}

.profile-tab {
  border: 1px solid var(--border, #d1d5db);
  border-radius: 999px;
  background: var(--surface, #fff);
  color: inherit;
  font: inherit;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
}

.profile-tab.is-active {
  border-color: var(--accent, #2563eb);
  background: color-mix(in srgb, var(--accent, #2563eb) 12%, white);
  font-weight: 600;
}

.access-forgot-password {
  margin: 0.35rem 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.access-forgot-password:hover {
  color: var(--accent-hover);
}

.access-reset-success {
  margin: 0.75rem 0 0;
  color: #166534;
  font-weight: 600;
}

.password-reveal-box {
  margin: 0 1rem 1rem;
  padding: 1rem;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
  text-align: center;
}

.password-reveal-box code {
  font-size: 1.35rem;
  letter-spacing: 0.04em;
}

.form-hint.is-warning {
  color: #b45309;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  z-index: 1000;
}

.modal-backdrop.open {
  display: flex;
}

.modal-backdrop--stack {
  z-index: 1100;
}

.modal-policy {
  width: min(560px, 100%);
}

.modal {
  width: min(520px, 100%);
  max-height: calc(100dvh - 2rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  padding: 1.25rem;
}

.modal-resident {
  width: min(720px, 100%);
}

.modal-sticky-head {
  margin-bottom: 1.25rem;
}

.modal-resident-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.modal-resident-head-main {
  min-width: 0;
  flex: 1;
}

.modal-resident-title-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.modal-resident-title-row h2 {
  margin: 0;
  font-size: 1.5rem;
}

.modal-resident-badges {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.modal-resident-badge {
  font-size: 1.35rem;
  line-height: 1;
}

.modal-resident-head .apartment-badge {
  margin-bottom: 0;
}

.modal-profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.modal-resident-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.modal-resident-layout #modal-photo .profile-photo {
  width: var(--profile-photo-zoom-width);
  height: var(--profile-photo-zoom-height);
  border-radius: 18px;
}

.modal-wide {
  width: min(720px, 100%);
}

@media (min-width: 1024px) {
  .modal-directory-window {
    width: min(
      calc(var(--layout-max-width) + (2 * var(--directory-overlay-edge))),
      calc(100vw - 2rem + (2 * var(--directory-overlay-inset)) + (2 * var(--directory-overlay-edge)))
    );
    height: calc((3 * 16.25rem) + (2 * 1.125rem));
    max-height: none;
  }
}

@media (max-width: 560px) {
  .modal-resident-layout {
    grid-template-columns: 1fr;
  }

  .modal-resident-layout #modal-photo .profile-photo {
    width: 100%;
    max-width: 240px;
    height: 300px;
    margin: 0 auto;
  }
}

.modal-subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.35rem;
}

.modal-close {
  border: none;
  background: #f1f5f9;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

body.modal-open {
  overflow: hidden;
  overscroll-behavior: none;
}

.detail-list {
  display: grid;
  gap: 0.85rem;
}

.detail-item {
  display: grid;
  gap: 0.2rem;
}

.detail-item dt {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}

.detail-item dd {
  margin: 0;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.chip-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 600;
}

.chip-link--telegram .chip-link-icon {
  display: inline-flex;
  color: #229ed9;
  flex-shrink: 0;
}

.chip-link--telegram .chip-link-action {
  color: var(--muted);
  font-weight: 500;
}

.chip-link--telegram:hover .chip-link-action {
  color: var(--accent);
}

.chip-link:hover {
  background: var(--accent-soft);
  border-color: #bfdbfe;
  text-decoration: none;
}

/* Admin */

.admin-layout {
  padding-bottom: 3rem;
}

.login-box {
  width: min(420px, 100%);
  margin: 4rem auto;
  padding: 1.5rem;
}

.login-box h2 {
  margin: 0 0 0.5rem;
}

.login-box p {
  margin: 0 0 1rem;
  color: var(--muted);
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.admin-table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

tr:hover td {
  background: #fbfdff;
}

.table-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  padding: 1rem;
}

.form-grid .field-wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0 1rem 1rem;
}

.form-hint {
  margin: 0 1rem 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.form-notice {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a5f;
  font-size: 0.92rem;
  line-height: 1.45;
}

.section-header {
  padding: 1rem 1rem 0.5rem;
}

.section-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.section-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1;
}


.admin-profile-list {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}


.admin-profile-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.admin-profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.btn-small {
  min-height: auto;
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
}

.requests-list {
  display: grid;
  gap: 0.85rem;
  padding: 0.75rem 1rem 1rem;
}

.request-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  background: #fbfdff;
}

.request-card-header h3 {
  margin: 0.35rem 0 0.15rem;
}

.request-card-header {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}
.profile-photo--sm {
  width: 72px;
  height: 72px;
}

.request-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.request-type {
  display: inline-flex;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.request-type.is-new {
  background: #dcfce7;
  color: var(--success);
}

.request-type.is-update {
  background: #fef3c7;
  color: #b45309;
}

.request-type.is-reset {
  background: #ede9fe;
  color: #6d28d9;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 1.6rem;
}

.checkbox-field input {
  width: auto;
}

.consent-field {
  padding: 0.25rem 0;
}

.contact-privacy-hint {
  margin: 0.45rem 0 0;
}

.contact-privacy-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.55rem;
  margin-bottom: 0;
  font-size: 0.84rem;
  line-height: 1.35;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.field label.contact-privacy-option {
  display: flex;
}

.contact-privacy-option input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}

.consent-label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.92rem;
  line-height: 1.45;
  cursor: pointer;
}

.consent-label input {
  width: auto;
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.consent-disclaimer {
  margin: 0.65rem 0 0 1.85rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.consent-policy-link {
  display: inline-block;
  margin: 0.5rem 0 0 1.85rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.consent-policy-link:hover {
  color: var(--accent-hover);
}

.policy-content {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
}

.policy-content ul {
  margin: 0;
  padding-left: 1.15rem;
}

.policy-content li + li {
  margin-top: 0.65rem;
}

.pwa-install-banner {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.pwa-install-banner.hidden {
  display: none;
}

.pwa-install-banner-text {
  display: grid;
  gap: 0.15rem;
  font-size: 0.88rem;
  color: var(--text);
}

.pwa-install-banner-text strong {
  font-size: 0.92rem;
}

.pwa-install-banner-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

@media (max-width: 1279px) {
  .pwa-install-banner {
    margin-inline: 0;
  }
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #111827;
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 2000;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.feedback-reply-notice-wrap {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(15, 23, 42, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.feedback-reply-notice-wrap.show {
  opacity: 1;
  pointer-events: auto;
}

.feedback-reply-notice {
  width: min(24rem, calc(100% - 2rem));
  margin: 0;
  padding: 1.25rem 1.35rem;
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: calc(var(--radius) + 2px);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  text-align: center;
  cursor: pointer;
  font: inherit;
  display: grid;
  gap: 0.45rem;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feedback-reply-notice-wrap.show .feedback-reply-notice {
  transform: translateY(0) scale(1);
}

.feedback-reply-notice:hover,
.feedback-reply-notice:focus-visible {
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.18);
  outline: none;
}

.feedback-reply-notice-title {
  display: block;
  font-size: 1.05rem;
  line-height: 1.35;
}

.feedback-reply-notice-hint {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    align-items: flex-start;
  }

  .modal {
    max-height: calc(100dvh - 1rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .modal-sticky-head,
  .modal-wide > .modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: -1.25rem -1.25rem 1rem;
    padding: 1.25rem 1.25rem 0.85rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .modal-sticky-head {
    margin-bottom: 1rem;
  }

  .modal-sticky-head .modal-profile-actions .btn {
    width: 100%;
  }

  .chip-link--telegram .chip-link-action {
    display: none;
  }
}

.directory-end-actions {
  padding-top: 0.5rem;
}

.directory-end-actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-right: var(--directory-overlay-edge);
  box-sizing: border-box;
}

.feedback-developer-contact {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.feedback-developer-contact a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.feedback-developer-contact a:hover {
  text-decoration: underline;
}

.feedback-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.feedback-archive-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}

.admin-settings-panel {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
}

.admin-stats-panel {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
}

.admin-stats-panel h2 {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
}

.admin-stats-summary {
  margin: 0;
}

.admin-stats-label {
  margin: 0.85rem 0 0.35rem;
}

.admin-missing-apartments {
  margin: 0;
  line-height: 1.55;
  word-break: break-word;
}

.admin-notify-toggle {
  margin-top: 1rem;
}

.admin-test-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.admin-settings-hint {
  margin: 0.55rem 0 0;
}

.feedback-list {
  display: grid;
  gap: 0.85rem;
  padding: 0.75rem 1rem 1rem;
}

.feedback-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  background: #fbfdff;
}

.feedback-card--new {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.feedback-card-header h3 {
  margin: 0.35rem 0 0.15rem;
}

.feedback-status {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.feedback-status--new {
  background: #dbeafe;
  color: #1d4ed8;
}

.feedback-status--read {
  background: #e5e7eb;
  color: #374151;
}

.feedback-status--archived {
  background: #f3f4f6;
  color: #6b7280;
}

.feedback-message {
  margin: 0.85rem 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.badge--inline {
  margin-left: 0.35rem;
  vertical-align: middle;
}

.feedback-threads-section {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.feedback-threads-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.feedback-threads-list {
  display: grid;
  gap: 0.85rem;
}

.feedback-thread {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  background: #f8fafc;
}

.feedback-thread--unread {
  border-color: #93c5fd;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.feedback-thread-message + .feedback-thread-message {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.feedback-thread-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.feedback-thread-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.feedback-thread-message--admin .feedback-thread-text {
  color: #1d4ed8;
}

.feedback-replies {
  display: grid;
  gap: 0.65rem;
  margin: 0.85rem 0;
  padding: 0.75rem;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.feedback-reply-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.feedback-reply-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.feedback-reply-form {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.feedback-reply-label {
  font-size: 0.88rem;
  font-weight: 600;
}

.feedback-reply-form textarea {
  width: 100%;
  min-height: 5.5rem;
  resize: vertical;
}

.documents-panel {
  display: grid;
  gap: 1rem;
}

.documents-archive-toggle,
.documents-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.documents-archive-toggle {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.documents-list {
  display: grid;
  gap: 0.85rem;
}

.document-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfdff;
}

.document-card--archived {
  opacity: 0.82;
  background: #f7f8fa;
}

.document-card-main {
  display: flex;
  gap: 0.85rem;
  min-width: 0;
  flex: 1;
}

.document-file-badge {
  flex: 0 0 auto;
  min-width: 3rem;
  padding: 0.45rem 0.5rem;
  border-radius: 10px;
  background: #e8f1ff;
  color: #1d4f91;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
}

.document-preview {
  position: relative;
  flex: 0 0 auto;
  width: 4.25rem;
  height: 5.4rem;
  overflow: hidden;
  border: 1px solid rgba(29, 79, 145, 0.16);
  border-radius: 8px;
  background: #e8f1ff;
  box-shadow: 0 0.25rem 0.75rem rgba(15, 23, 42, 0.08);
}

.document-preview-frame {
  position: relative;
  z-index: 1;
  width: 180%;
  height: 180%;
  border: 0;
  transform: scale(0.56);
  transform-origin: 0 0;
  pointer-events: none;
  background: #fff;
}

.document-preview-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #1d4f91;
  font-size: 0.78rem;
  font-weight: 700;
}

.document-card-body {
  min-width: 0;
}

.document-card-title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  line-height: 1.3;
}

.document-card-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.document-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.document-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #eef2f7;
  color: #415066;
  font-size: 0.78rem;
}

.document-download-btn {
  flex: 0 0 auto;
  align-self: center;
}

.document-card--admin {
  flex-direction: column;
}

.document-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.document-upload-form {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--border);
}

.document-upload-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: end;
}

.documents-archive-block {
  display: grid;
  gap: 0.75rem;
}

.documents-archive-title {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

@media (max-width: 720px) {
  .document-card {
    flex-direction: column;
  }

  .document-download-btn,
  .document-card-actions {
    width: 100%;
  }

  .document-card-actions .btn,
  .document-download-btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .document-upload-grid {
    grid-template-columns: 1fr;
  }

  .header-actions .btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }
}

.events-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.events-toolbar label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.events-form {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfdff;
}

.events-list {
  display: grid;
  gap: 0.85rem;
}

.event-card {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfdff;
}

.event-card--archived {
  opacity: 0.78;
  background: #f7f8fa;
}

.event-card-head,
.event-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.event-card-head h3 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.event-card-head p,
.event-description {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.event-status,
.event-counter {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  background: #eef2ff;
  color: #1d4ed8;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.event-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.event-meta strong {
  color: var(--text);
}

.event-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Запись на событие: обе кнопки синие; выбранная гаснет и меняет цвет */
.event-actions .btn:disabled {
  cursor: default;
}

.event-actions .btn-primary.is-active,
.event-actions .btn-primary.is-active:disabled {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}

.event-actions .btn-primary.is-active::before {
  content: "✓ ";
}

.event-actions .btn[data-event-action="decline"].is-active,
.event-actions .btn[data-event-action="decline"].is-active:disabled {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}

.events-archive-title {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

@media (max-width: 720px) {
  .events-toolbar,
  .event-card-head,
  .event-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .events-toolbar .btn,
  .events-toolbar label,
  .event-actions .btn {
    width: 100%;
  }

  .event-meta {
    grid-template-columns: 1fr;
  }

  .event-actions {
    justify-content: stretch;
  }
}

.event-chat {
  display: grid;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.event-chat-list {
  display: grid;
  gap: 0.65rem;
  max-height: min(32rem, 60dvh);
  overflow: auto;
  padding-right: 0.25rem;
}

.event-chat-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.event-chat-message {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.55rem;
  align-items: start;
}

.avatar--xs {
  width: 2rem;
  height: 2rem;
  border-radius: 9px;
  font-size: 0.9rem;
}

.event-chat-bubble {
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  background: #f8fafc;
}

.event-chat-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.event-chat-meta strong {
  color: var(--text);
  font-size: 0.85rem;
}

.event-chat-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}

.event-chat-form {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.5rem;
}

.event-chat-form input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.65rem 0.8rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.event-chat-form input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--accent);
}

@media (max-width: 720px) {
  .event-chat-list {
    max-height: 15rem;
  }

  .event-chat-form {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .event-chat-form .btn {
    grid-column: 1 / -1;
  }

  .event-chat-form input {
    min-height: 3rem;
  }

  .event-chat-smileys {
    width: 3rem;
  }
}

.event-chat-toggle {
  position: relative;
  gap: 0.35rem;
}

.event-chat-unread-dot {
  display: none;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
}

.event-chat-toggle.has-unread .event-chat-unread-dot {
  display: inline-block;
  animation: event-chat-pulse 1.1s ease-in-out infinite;
}

@keyframes event-chat-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  }
  70% {
    box-shadow: 0 0 0 0.42rem rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.event-subscription-toggle {
  display: inline-flex !important;
  align-items: center;
  gap: 0.45rem !important;
  color: var(--text) !important;
  font-weight: 600;
}

.event-card--admin .form-grid {
  margin-top: 0.25rem;
}

/* Фото события в карточке */
.event-photo {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
}

.event-photo-zoom {
  cursor: zoom-in;
}

.event-photo-zoom .photo-zoom-popover {
  left: 0;
  right: auto;
  top: calc(100% + 0.5rem);
  transform: none;
}

.event-photo-zoom .photo-zoom-popover img {
  display: block;
  width: min(420px, 72vw);
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
}

/* Поле фото в форме события */
.event-form-photo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.event-form-photo-preview {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.event-form-photo-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Смайлы в чате событий */
.event-chat-smileys {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  width: 2.75rem;
  font-size: 1.15rem;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.event-chat-smileys:hover {
  border-color: var(--accent);
}

.smiley-picker {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.5rem);
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 2.1rem);
  gap: 0.15rem;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
}

.smiley-option {
  padding: 0.28rem;
  font-size: 1.25rem;
  line-height: 1;
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.smiley-option:hover {
  background: rgba(37, 99, 235, 0.12);
}

.smiley {
  display: inline-block;
  font-size: 1.45em;
  line-height: 1;
  vertical-align: -0.28em;
  margin: 0 0.06em;
}

.smiley--bounce { animation: sm-bounce 1.8s ease-in-out infinite; }
.smiley--wink { animation: sm-wink 2.2s ease-in-out infinite; }
.smiley--laugh { animation: sm-laugh 0.9s ease-in-out infinite; }
.smiley--droop { animation: sm-droop 2.6s ease-in-out infinite; }
.smiley--pulse { animation: sm-pulse 1.4s ease-in-out infinite; }
.smiley--kiss { animation: sm-kiss 1.6s ease-in-out infinite; }
.smiley--wiggle { animation: sm-wiggle 0.8s ease-in-out infinite; }
.smiley--pop { animation: sm-pop 1.5s ease-in-out infinite; }
.smiley--tilt { animation: sm-tilt 2.4s ease-in-out infinite; }
.smiley--blush { animation: sm-blush 2s ease-in-out infinite; }
.smiley--shake { animation: sm-shake 0.5s ease-in-out infinite; }
.smiley--glide { animation: sm-glide 2s ease-in-out infinite; }
.smiley--float { animation: sm-float 2.4s ease-in-out infinite; }
.smiley--breathe { animation: sm-breathe 3.2s ease-in-out infinite; }
.smiley--twinkle { animation: sm-twinkle 1.2s ease-in-out infinite; }
.smiley--dance { animation: sm-dance 1s ease-in-out infinite; }
.smiley--heartbeat { animation: sm-heartbeat 1.2s ease-in-out infinite; }

@keyframes sm-bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-0.18em); }
  50% { transform: translateY(0.04em) scale(1.04); }
}

@keyframes sm-wink {
  0%, 40%, 100% { transform: scaleX(1); }
  50% { transform: scaleX(0.6) rotate(8deg); }
  60% { transform: scaleX(1); }
}

@keyframes sm-laugh {
  0%, 100% { transform: rotate(-8deg) scale(1); }
  50% { transform: rotate(8deg) scale(1.15); }
}

@keyframes sm-droop {
  0%, 100% { transform: translateY(0.12em) scale(0.96); }
  50% { transform: translateY(0.2em) scale(0.9); }
}

@keyframes sm-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

@keyframes sm-kiss {
  0%, 70%, 100% { transform: translateX(0) scale(1); }
  80% { transform: translateX(0.12em) scale(1.12); }
}

@keyframes sm-wiggle {
  0%, 100% { transform: rotate(-10deg); }
  50% { transform: rotate(10deg); }
}

@keyframes sm-pop {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(0.85); }
  60% { transform: scale(1.25); }
}

@keyframes sm-tilt {
  0%, 100% { transform: rotate(6deg); }
  50% { transform: rotate(-6deg); }
}

@keyframes sm-blush {
  0%, 100% { filter: saturate(1); transform: scale(1); }
  50% { filter: saturate(1.6) hue-rotate(-8deg); transform: scale(1.08); }
}

@keyframes sm-shake {
  0%, 100% { transform: translateX(-0.08em); }
  50% { transform: translateX(0.08em); }
}

@keyframes sm-glide {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-0.14em) rotate(-6deg); }
}

@keyframes sm-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-0.22em); }
}

@keyframes sm-breathe {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.75; }
}

@keyframes sm-twinkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.25) rotate(18deg); opacity: 0.7; }
}

@keyframes sm-dance {
  0%, 100% { transform: rotate(-12deg) translateY(0); }
  25% { transform: rotate(0deg) translateY(-0.12em); }
  50% { transform: rotate(12deg) translateY(0); }
  75% { transform: rotate(0deg) translateY(-0.12em); }
}

@keyframes sm-heartbeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.22); }
  30% { transform: scale(1); }
  45% { transform: scale(1.18); }
}

@media (prefers-reduced-motion: reduce) {
  .smiley {
    animation: none !important;
  }
}

.event-photo--admin {
  width: 48px;
  height: 48px;
  border-radius: 10px;
}

/* Индикатор новых событий на кнопке в шапке */
#header-events {
  position: relative;
}

#header-events.has-unread::after {
  content: "";
  position: absolute;
  top: -0.3rem;
  right: -0.3rem;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: #22c55e;
  animation: event-chat-pulse 1.1s ease-in-out infinite;
}

#header-polls.has-unread::after {
  content: '';
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 2px var(--surface, #111);
}

#header-polls {
  position: relative;
}

.poll-card h3 {
  white-space: pre-wrap;
}

.poll-options {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.poll-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  cursor: pointer;
}

.poll-option em {
  margin-left: auto;
  color: var(--accent);
  font-style: normal;
  font-weight: 700;
}

.poll-voters {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Глобальный чат */
#header-chat {
  position: relative;
}

#header-chat.has-unread::after {
  content: "";
  position: absolute;
  top: -0.3rem;
  right: -0.3rem;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: #22c55e;
  animation: event-chat-pulse 1.1s ease-in-out infinite;
}

.chat-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.chat-channels {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: min(34rem, 62dvh);
  overflow: auto;
  padding-right: 0.25rem;
}

.chat-channel {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  color: var(--text);
}

.chat-channel:hover {
  border-color: var(--accent);
}

.chat-channel.is-active {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
  font-weight: 600;
}

.chat-channel-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #22c55e;
  animation: event-chat-pulse 1.1s ease-in-out infinite;
  flex-shrink: 0;
}

.chat-channel-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-pane {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
}

.chat-pane-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.chat-channel-hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.chat-smiley-picker {
  right: auto;
  left: 0;
}

@media (max-width: 720px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .chat-channels {
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
    padding-bottom: 0.25rem;
  }

  .chat-channel {
    flex: 0 0 auto;
  }
}

/* Композер сообщения и оригинальные ICQ-гифки */
.chat-composer {
  min-height: 2.75rem;
  padding: 0.55rem 0.8rem;
  font-size: 1rem;
  line-height: 1.35;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 8rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-composer:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--accent);
}

.chat-composer:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
}

.chat-composer[contenteditable="false"] {
  background: #f1f5f9;
  cursor: not-allowed;
}

.smiley-gif {
  height: 1.35em;
  width: auto;
  vertical-align: -0.3em;
  margin: 0 0.06em;
  display: inline-block;
}

.chat-composer .smiley-gif {
  height: 1.5em;
}

.event-chat-smileys-img {
  width: 1.35em;
  height: 1.35em;
  display: block;
}

.smiley-picker--gif {
  grid-template-columns: repeat(8, 2.35rem);
}

.smiley-picker--gif .smiley-option {
  padding: 0.18rem;
}

.smiley-picker--gif .smiley-option img {
  width: 1.8em;
  height: 1.8em;
  display: block;
}

@media (max-width: 720px) {
  .smiley-picker--gif {
    grid-template-columns: repeat(6, 2.5rem);
  }
}

/* Реакции и ответы на сообщения */
.event-chat-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.3rem;
}

.chat-react,
.chat-reply-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.45rem;
  font-size: 0.82rem;
  line-height: 1.2;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.chat-react:hover,
.chat-reply-btn:hover {
  background: rgba(37, 99, 235, 0.08);
  color: var(--text);
}

.chat-react.is-active {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--text);
}

.chat-react--dislike.is-active {
  background: rgba(220, 38, 38, 0.1);
  border-color: rgba(220, 38, 38, 0.3);
}

.chat-react-count:empty {
  display: none;
}

.event-chat-reply {
  margin-bottom: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-left: 3px solid var(--accent);
  background: rgba(37, 99, 235, 0.06);
  border-radius: 0 8px 8px 0;
  font-size: 0.82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.event-chat-reply-name {
  font-weight: 600;
  color: var(--text);
}

.chat-reply-preview {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.35rem;
  border-left: 3px solid var(--accent);
  background: rgba(37, 99, 235, 0.06);
  border-radius: 0 8px 8px 0;
  font-size: 0.85rem;
  color: var(--muted);
  grid-column: 1 / -1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-reply-preview.hidden {
  display: none;
}

.chat-reply-cancel {
  margin-left: auto;
  border: 0;
  background: none;
  font-size: 1rem;
  color: var(--muted);
  cursor: pointer;
}

.marketplace-toolbar {
  align-items: center;
}

.marketplace-note,
.marketplace-photo-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.marketplace-card-head {
  align-items: center;
}

.marketplace-card-main {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(150px, 0.45fr) minmax(260px, 0.95fr) minmax(130px, 0.35fr);
  gap: 1.25rem;
  align-items: center;
}

.marketplace-photos,
.marketplace-photo-previews {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.marketplace-photo {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.marketplace-photo-zoom {
  cursor: zoom-in;
}

.marketplace-photo-zoom:hover .photo-zoom-popover,
.marketplace-photo-zoom:focus-within .photo-zoom-popover {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.marketplace-photo-zoom.is-open .photo-zoom-popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.marketplace-photo-zoom.is-open::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  z-index: 1190;
}

.marketplace-photo-zoom .photo-zoom-popover {
  position: fixed;
  left: 50%;
  right: auto;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1200;
  display: block;
}

.marketplace-photo-zoom .photo-zoom-popover img {
  display: block;
  width: auto;
  height: min(760px, calc(100dvh - 2rem));
  max-width: calc(100vw - 2rem);
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
}

.marketplace-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.65rem;
  margin: 0;
}

.marketplace-meta span {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.15rem;
}

.marketplace-meta small {
  color: var(--muted);
  font-size: 0.82rem;
}

.marketplace-meta strong {
  min-width: 0;
  color: var(--text);
  font-weight: 700;
}

.marketplace-meta span strong {
  white-space: nowrap;
}

.marketplace-price {
  display: grid;
  gap: 0.35rem;
  align-content: center;
  min-width: 0;
  padding-right: 1.25rem;
  border-right: 1px solid var(--border);
}

.marketplace-price small {
  color: var(--muted);
  font-size: 0.82rem;
}

.marketplace-price strong {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text);
  font-size: 2.6rem;
  line-height: 1.05;
  white-space: nowrap;
}

.marketplace-currency-icon {
  display: inline-block;
  width: 0.72em;
  height: 0.88em;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: url("/icons/byn-ico.svg") center / contain no-repeat;
  mask: url("/icons/byn-ico.svg") center / contain no-repeat;
}

.marketplace-remaining {
  display: grid;
  gap: 0.35rem;
  min-height: 5.5rem;
  align-content: center;
  padding: 0.85rem 1rem;
  border-left: 1px solid var(--border);
  text-align: center;
}

.marketplace-remaining span {
  color: var(--muted);
  font-size: 0.82rem;
}

.marketplace-remaining strong {
  color: var(--accent);
  font-size: 2.6rem;
  line-height: 1.05;
  white-space: nowrap;
}

.marketplace-card .event-description a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.marketplace-photo-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.68);
  color: #fff;
  cursor: pointer;
  font: 2rem/1 var(--font);
  transform: translateY(-50%);
  transition: background 0.15s ease, transform 0.15s ease;
}

.marketplace-photo-nav:hover,
.marketplace-photo-nav:focus-visible {
  background: rgba(15, 23, 42, 0.9);
  outline: none;
  transform: translateY(-50%) scale(1.06);
}

.marketplace-photo-nav--prev {
  left: 0.75rem;
}

.marketplace-photo-nav--next {
  right: 0.75rem;
}

.marketplace-photo-counter {
  position: absolute;
  left: 50%;
  bottom: 0.75rem;
  z-index: 2;
  padding: 0.3rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1;
  transform: translateX(-50%);
  pointer-events: none;
}

.marketplace-no-photo {
  display: grid;
  place-items: center;
  min-height: 5.5rem;
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(248, 250, 252, 0.78);
}

.marketplace-preview-item {
  display: grid;
  gap: 0.35rem;
  width: 96px;
}

.marketplace-preview-item img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.marketplace-preview-item .btn {
  width: 100%;
  padding-inline: 0.35rem;
  font-size: 0.78rem;
}

@media (max-width: 720px) {
  .marketplace-photo {
    width: 84px;
    height: 84px;
  }

  .marketplace-photo-zoom .photo-zoom-popover img {
    width: min(92vw, 420px);
  }
}

@media (max-width: 900px) {
  .marketplace-card-main {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .marketplace-remaining {
    min-height: 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .marketplace-meta {
    gap: 0.65rem;
  }

  .marketplace-price {
    padding: 0 0 0.65rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}
@media (max-width: 720px) and (orientation: portrait) {
  #marketplace-modal {
    padding: max(0.5rem, env(safe-area-inset-top)) max(0.45rem, env(safe-area-inset-right))
      max(0.5rem, env(safe-area-inset-bottom)) max(0.45rem, env(safe-area-inset-left));
  }

  #marketplace-modal .modal-wide {
    width: min(100%, calc(100vw - 0.9rem));
    max-width: calc(100vw - 0.9rem);
    padding: 1rem;
    overflow-x: hidden;
  }

  #marketplace-modal .modal-wide > .modal-header {
    margin: -1rem -1rem 0.85rem;
    padding: 1rem 1rem 0.85rem;
    gap: 0.75rem;
  }

  #marketplace-modal .modal-header h2 {
    font-size: 1.55rem;
    line-height: 1.15;
  }

  #marketplace-modal .modal-header p {
    font-size: 1rem;
    line-height: 1.35;
  }

  #marketplace-modal .modal-close {
    width: 3.1rem;
    height: 3.1rem;
    flex: 0 0 auto;
  }

  #marketplace-list,
  #marketplace-list .event-list,
  .marketplace-card,
  .marketplace-card-head,
  .marketplace-card-main,
  .marketplace-photos,
  .marketplace-no-photo,
  .marketplace-price,
  .marketplace-meta,
  .marketplace-remaining,
  .marketplace-card .event-description,
  .marketplace-card .event-actions {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  .marketplace-card {
    overflow: hidden;
    padding: 1rem;
  }

  #marketplace-modal:has(.marketplace-photo-zoom.is-open),
  #marketplace-modal .modal-wide:has(.marketplace-photo-zoom.is-open),
  #marketplace-modal .marketplace-card:has(.marketplace-photo-zoom.is-open),
  #marketplace-modal .marketplace-photos:has(.marketplace-photo-zoom.is-open) {
    overflow: visible;
  }

  #marketplace-modal .marketplace-card:has(.marketplace-photo-zoom.is-open) {
    position: relative;
    z-index: 1500;
  }

  #marketplace-modal .marketplace-photo-zoom.is-open::before {
    z-index: 1800;
  }

  #marketplace-modal .marketplace-photo-zoom.is-open .photo-zoom-popover {
    position: fixed;
    left: 50%;
    top: 50%;
    right: auto;
    z-index: 1810;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, -50%);
  }

  #marketplace-modal .marketplace-photo-zoom.is-open .photo-zoom-popover img {
    width: auto;
    height: auto;
    max-width: calc(100vw - 1.5rem);
    max-height: calc(100dvh - 1.5rem);
    object-fit: contain;
  }

  .marketplace-card-main {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .marketplace-photos {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    scrollbar-width: thin;
  }

  .marketplace-photo {
    width: 78px;
    height: 78px;
  }

  .marketplace-price {
    padding: 0 0 0.75rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .marketplace-price strong,
  .marketplace-remaining strong {
    font-size: clamp(2.35rem, 14vw, 3.2rem);
  }

  .marketplace-meta span strong {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .marketplace-remaining {
    min-height: 0;
    padding: 0.75rem 0 0;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .marketplace-card .event-description,
  .marketplace-card .event-description a {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .marketplace-card .event-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .marketplace-card .event-actions .btn {
    width: 100%;
  }
}
