:root {
  --bg: #f4f1ea;
  --panel: #fffdf7;
  --text: #1f1c17;
  --muted: #6b665d;
  --accent: #0d6e6e;
  --danger: #c44536;
  --success: #2c8c42;
  --warning: #c17a00;
  --border: #e5dfd2;
  --shadow: 0 12px 30px rgba(23, 26, 31, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Avenir Next', 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at 10% 0%, #d7ebe8 0%, rgba(215, 235, 232, 0) 42%),
    radial-gradient(circle at 100% 20%, #f0dfc8 0%, rgba(240, 223, 200, 0) 38%),
    var(--bg);
  color: var(--text);
}

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

.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(2px);
}

h1,
h2,
h3 {
  margin: 0 0 10px;
  letter-spacing: 0.2px;
}

.muted {
  color: var(--muted);
}

.warning-text {
  color: var(--warning);
}

#admin-message-toast {
  margin-bottom: 12px;
  border-color: var(--accent);
}

.rules-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 14px;
  background: #fff;
}

.rules-text {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
}

.global-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1500;
  min-width: 240px;
  max-width: min(90vw, 440px);
  padding: 12px 14px;
  border-radius: 12px;
  color: #fff;
  box-shadow: var(--shadow);
}

.global-toast.info {
  background: #225f7f;
}

.global-toast.success {
  background: #2c8c42;
}

.global-toast.error {
  background: #b43232;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 12px rgba(13, 110, 110, 0.2);
}

button:hover {
  filter: brightness(1.03);
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  background: #6a7176;
}

button.danger {
  background: var(--danger);
}

button.success {
  background: var(--success);
}

button.warning {
  background: var(--warning);
}

.tabs button {
  background: #d6d1c4;
  color: #2c2924;
}

.tabs button.active {
  background: var(--accent);
  color: white;
}

.admin-tab-btn {
  background: #d6d1c4;
  color: #2c2924;
  box-shadow: none;
}

.admin-tab-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 14px rgba(13, 110, 110, 0.26);
}

.admin-tab-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.theme-preview-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #f9f6ef;
}

.theme-preview-shell {
  border-radius: 10px;
  border: 1px solid #d8d2c4;
  padding: 12px;
}

.theme-preview-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.theme-preview-title {
  margin: 0 0 8px;
}

.theme-preview-text {
  margin: 0 0 12px;
}

.theme-preview-button {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
}

.form,
.grid-4,
.grid-3,
.grid-2 {
  display: grid;
  gap: 10px;
}

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

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: white;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #69a6a6;
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.14);
}

fieldset {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

legend {
  padding: 0 6px;
  color: var(--muted);
}

label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pref-genders-fieldset {
  padding: 10px;
  gap: 8px;
}

.pref-genders-fieldset legend {
  font-weight: 600;
}

.pref-genders-fieldset label {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.pref-genders-fieldset label:has(input:checked) {
  border-color: var(--accent);
  background: #eaf7f5;
}

.pref-genders-fieldset input[type='checkbox'] {
  accent-color: var(--accent);
}

.error {
  min-height: 24px;
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  margin-left: 4px;
  padding: 0 5px;
}

.card {
  margin-bottom: 14px;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.card.loading {
  opacity: 0.72;
}

.card.swipe-right {
  transform: translateX(28px) rotate(2.8deg);
}

.card.swipe-left {
  transform: translateX(-28px) rotate(-2.8deg);
}

.card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}

.card-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  background: #fff;
  font-size: 13px;
  color: #36332d;
}

.profile-image {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  cursor: zoom-in;
}

.profile-gallery {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.profile-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: pointer;
}

.profile-thumb.active {
  border-color: var(--accent);
}

.actions,
.secondary-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.actions button,
.secondary-actions button {
  flex: 1;
}

#matches,
#user-admin-inbox-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

#matches li,
#user-admin-inbox-list li {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  white-space: pre-wrap;
}

.match-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.match-content {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.match-actions {
  display: flex;
  gap: 8px;
}

.match-image {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--border);
  cursor: zoom-in;
}

.chat-messages {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 8px;
  background: #fff;
}

.chat-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  white-space: pre-wrap;
  background: #ffffff;
}

.chat-item.mine {
  background: #eaf7f5;
}

.chat-form {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.chat-form input {
  flex: 1;
}

.section-gap {
  margin-top: 20px;
}

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

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.profile-form {
  gap: 12px;
}

.profile-stepper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.profile-step-btn {
  background: #d6d1c4;
  color: #2c2924;
  box-shadow: none;
  font-size: 13px;
}

.profile-step-btn.active {
  background: var(--accent);
  color: #fff;
}

.profile-form-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 10px;
}

.profile-form-section h4 {
  margin: 0;
  font-size: 14px;
  color: #3b3832;
}

.profile-step-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

#delete-profile-btn {
  width: 100%;
  margin-top: 10px;
}

.onboarding-card {
  width: min(620px, 100%);
}

.onboarding-progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e4ddd0;
  overflow: hidden;
  margin-bottom: 12px;
}

.onboarding-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #0d6e6e, #31a7a7);
  transition: width 0.2s ease;
}

.onboarding-slide h4 {
  margin: 0 0 6px;
}

.chat-window-card {
  width: min(980px, 100%);
}

.image-lightbox-card {
  width: min(1000px, 100%);
}

.image-lightbox-img {
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

.chat-window-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 12px;
}

.chat-window-sidebar {
  border-right: 1px solid var(--border);
  padding-right: 10px;
}

.chat-window-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-match-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.chat-match-list li button {
  width: 100%;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-list-btn {
  gap: 10px;
}

.chat-list-main {
  display: grid;
  gap: 2px;
}

.chat-list-main small {
  opacity: 0.9;
}

.chat-list-side {
  display: grid;
  gap: 5px;
  justify-items: end;
}

.chat-list-btn.has-unread {
  box-shadow: 0 0 0 2px rgba(196, 69, 54, 0.2);
}

.skeleton-line {
  background: linear-gradient(90deg, #ece8de 25%, #f7f4ec 37%, #ece8de 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s infinite linear;
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 48px;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

.mobile-bottom-bar {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 1200;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 253, 247, 0.96);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: none;
  gap: 8px;
}

.mobile-bottom-bar button {
  flex: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: top;
}

thead th {
  position: sticky;
  top: 0;
  background: #fff9ef;
  z-index: 1;
}

td button {
  margin-right: 6px;
  margin-bottom: 6px;
}

@media (max-width: 860px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .container {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 14px;
  }

  .app-header {
    flex-direction: column;
    gap: 8px;
  }

  .header-actions,
  .match-actions,
  .chat-form,
  .actions,
  .secondary-actions {
    flex-direction: column;
    width: 100%;
  }

  .match-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  fieldset {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-window-layout {
    grid-template-columns: 1fr;
  }

  .chat-window-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 10px;
  }

  .admin-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-tab-btn {
    width: 100%;
  }

  .modal-card {
    width: 100%;
    max-height: 94vh;
    padding: 12px;
  }

  .profile-stepper {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-step-actions {
    flex-direction: column;
  }

  .mobile-bottom-bar {
    display: flex;
  }

  body {
    padding-bottom: 78px;
  }
}
