:root {
  --bg: #fff6f9;
  --surface: #fff;
  --ink: #3b1d28;
  --muted: #8d6b77;
  --line: #f1dbe3;
  --soft: #fff0f5;
  --primary: #f4517a;
  --primary-dark: #d93d68;
  --danger: #d93838;
  --success: #16834b;
  --radius: 20px;
  --shadow: 0 18px 55px rgba(127, 42, 72, .13);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
html { background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
svg { display: block; }

.social-app { min-height: 100vh; }
.social-topbar {
  position: sticky; top: 0; z-index: 30; height: 68px;
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92);
  backdrop-filter: blur(18px);
}
.social-topbar-inner {
  max-width: 1160px; height: 100%; margin: auto; padding: 0 24px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
}
.social-brand { display: inline-flex; align-items: center; gap: 10px; width: max-content; font-weight: 800; letter-spacing: -.03em; font-size: 19px; }
.brand-mark {
  width: 26px; height: 25px; position: relative; flex: 0 0 auto;
  color: var(--primary); border-left: 5px solid currentColor; border-right: 5px solid currentColor;
  border-bottom: 5px solid currentColor; border-top: 0; border-radius: 0 0 15px 15px;
  box-sizing: border-box; transform: scale(.88); transform-origin: left bottom;
}
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; background: currentColor; }
.brand-mark::before { width: 5px; height: 11px; right: -5px; top: -1px; border-radius: 0 0 3px 3px; }
.brand-mark::after {
  width: 4px; height: 4px; left: 9px; top: -9px; border-radius: 1px;
  box-shadow: 6px 3px 0 currentColor, 12px 7px 0 currentColor, 6px -5px 0 currentColor;
}
.modal-logo {
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px;
  color: var(--primary); background: var(--soft);
}
.modal-logo .brand-mark {
  color: var(--primary); transform: scale(1.08); transform-origin: center bottom;
}
.desktop-nav { display: flex; align-items: center; gap: 6px; height: 100%; }
.desktop-nav a { position: relative; padding: 11px 18px; border-radius: 12px; color: var(--muted); font-size: 14px; font-weight: 700; }
.desktop-nav a:hover, .desktop-nav a.is-active { color: var(--primary-dark); background: var(--soft); }
.top-actions { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: 10px; }
.language-button, .avatar-button, .icon-button {
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.language-button { height: 36px; min-width: 42px; padding: 0 10px; border-radius: 10px; font-size: 12px; font-weight: 800; }
.avatar-button { width: 38px; height: 38px; overflow: hidden; border-radius: 50%; font-weight: 800; }
.avatar-button img { width: 100%; height: 100%; object-fit: cover; }
.icon-button { width: 40px; height: 40px; border-radius: 12px; }
.icon-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back-button { display: none; }
.nav-badge {
  position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px;
  display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--primary);
  font-size: 10px; font-weight: 800;
}
.social-main { max-width: 1160px; min-height: calc(100vh - 68px); margin: auto; padding: 28px 24px 60px; }
.mobile-tabs { display: none; }

.page { animation: page-in .18s ease-out; }
@keyframes page-in { from { opacity: .35; transform: translateY(5px); } }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1, .page-head h2 { margin: 0; letter-spacing: -.04em; }
.page-head h1 { font-size: clamp(28px, 4vw, 42px); }
.page-head p { margin: 5px 0 0; color: var(--muted); }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.muted { color: var(--muted); }
.empty-state { padding: 52px 24px; text-align: center; }
.empty-state-icon { margin: 0 auto 16px; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); font-size: 25px; }
.empty-state h2 { margin: 0 0 8px; }
.empty-state p { max-width: 420px; margin: auto; color: var(--muted); line-height: 1.55; }
.loading { padding: 72px 20px; text-align: center; color: var(--muted); }
.spinner { width: 26px; height: 26px; margin: 0 auto 12px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.button {
  min-height: 44px; padding: 0 18px; border: 1px solid var(--primary); border-radius: 13px;
  background: #fff; cursor: pointer; font-weight: 750; transition: .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button.primary { color: #fff; background: var(--primary); }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { border-color: var(--line); background: var(--soft); }
.button.danger { color: #fff; border-color: var(--danger); background: var(--danger); }
.button.text { border-color: transparent; background: transparent; color: var(--muted); }
.button.small { min-height: 36px; padding: 0 13px; border-radius: 10px; font-size: 13px; }
.button.full { width: 100%; }
.button + .button.full, .modal-action { margin-top: 10px; }

.match-shell { min-height: calc(100vh - 156px); display: grid; place-items: center; }
.match-stage { width: min(100%, 430px); }
.match-card {
  position: relative; aspect-ratio: .79; overflow: hidden; border-radius: 28px;
  background: #e9e9e6; box-shadow: var(--shadow); touch-action: pan-y;
  transition: transform .22s ease, opacity .22s ease;
}
.match-card.is-dragging { transition: none; }
.match-card.is-left { transform: translateX(-130%) rotate(-14deg); opacity: 0; }
.match-card.is-right { transform: translateX(130%) rotate(14deg); opacity: 0; }
.match-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.match-photo-fallback { width: 100%; height: 100%; display: grid; place-items: center; font-size: 92px; font-weight: 900; color: #aaa; background: linear-gradient(145deg,#f4f4f1,#d8d8d3); }
.match-shade { position: absolute; inset: 38% 0 0; background: linear-gradient(transparent, rgba(0,0,0,.78)); }
.match-info { position: absolute; left: 0; right: 0; bottom: 0; padding: 28px; color: #fff; }
.match-name { display: flex; align-items: center; gap: 9px; margin: 0; font-size: 29px; letter-spacing: -.04em; }
.verified { width: 19px; height: 19px; display: inline-grid; place-items: center; border-radius: 50%; color: #fff; background: var(--primary); font-size: 11px; flex: none; }
.match-card .verified, .profile-hero .verified { color: var(--primary); background: #fff; }
.match-meta { margin-top: 5px; opacity: .8; font-size: 14px; }
.match-bio { margin: 12px 0 0; line-height: 1.45; }
.swipe-label { position: absolute; top: 32px; z-index: 2; padding: 7px 12px; border: 3px solid; border-radius: 8px; font-size: 24px; font-weight: 900; opacity: 0; }
.swipe-label.nope { left: 24px; color: #ff6666; transform: rotate(-12deg); }
.swipe-label.like { right: 24px; color: #76edaa; transform: rotate(12deg); }
.match-actions { display: flex; justify-content: center; gap: 20px; margin-top: 22px; }
.swipe-button { width: 62px; height: 62px; border: 0; border-radius: 50%; cursor: pointer; background: #fff; box-shadow: 0 9px 25px rgba(0,0,0,.1); font-size: 25px; }
.swipe-button.like { color: #fff; background: var(--primary); }

.match-celebration { text-align: center; padding: 34px; }
.match-celebration-avatars { display: flex; justify-content: center; margin: 16px 0 22px; }
.match-celebration-avatars .avatar + .avatar { margin-left: -16px; }
.match-celebration h2 { margin: 0; font-size: 30px; }

.chats-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; min-height: 620px; }
.list-panel { overflow: hidden; }
.list-panel-head { padding: 20px; border-bottom: 1px solid var(--line); }
.list-panel-head h1 { margin: 0; font-size: 25px; }
.thread-list { display: grid; }
.thread-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.thread-row:hover { background: #fafaf8; }
.thread-body { min-width: 0; }
.thread-title { display: flex; gap: 6px; align-items: center; font-weight: 800; }
.thread-preview { margin-top: 4px; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-side { text-align: right; color: var(--muted); font-size: 11px; }
.thread-unread { width: 18px; height: 18px; margin: 5px 0 0 auto; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--primary); font-size: 10px; font-weight: 800; }
.friends-strip { display: flex; gap: 14px; overflow-x: auto; padding: 16px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.friends-strip::-webkit-scrollbar { display: none; }
.friend-chip { min-width: 62px; max-width: 72px; text-align: center; font-size: 12px; }
.friend-chip .avatar { margin: auto auto 5px; }
.friend-chip span { display: block; overflow: hidden; text-overflow: ellipsis; }
.chat-placeholder { display: grid; place-items: center; text-align: center; color: var(--muted); }

.chat-page { max-width: 820px; margin: auto; }
.chat-card { height: calc(100vh - 126px); min-height: 520px; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.chat-head-info { flex: 1; min-width: 0; }
.chat-head-name { display: flex; align-items: center; gap: 6px; font-weight: 800; }
.chat-head-status { color: var(--muted); font-size: 12px; }
.messages { overflow-y: auto; padding: 22px; background: #f8f8f5; }
.message-row { display: flex; margin: 8px 0; }
.message-row.mine { justify-content: flex-end; }
.message-bubble { max-width: min(75%, 560px); padding: 10px 13px 7px; border: 1px solid var(--line); border-radius: 17px 17px 17px 5px; background: #fff; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-row.mine .message-bubble { color: #fff; border-color: var(--primary); border-radius: 17px 17px 5px 17px; background: var(--primary); }
.message-time { display: block; margin-top: 4px; font-size: 10px; text-align: right; opacity: .58; }
.message-report { display: block; margin: 3px 0 0 auto; padding: 0; border: 0; background: transparent; color: inherit; font-size: 10px; opacity: .55; cursor: pointer; }
.message-report:hover { opacity: 1; text-decoration: underline; }
.message-form { display: flex; gap: 10px; padding: 13px; border-top: 1px solid var(--line); background: #fff; }
.message-form textarea { flex: 1; min-height: 44px; max-height: 120px; resize: none; }

.avatar { width: 48px; height: 48px; overflow: hidden; display: grid; place-items: center; flex: none; border-radius: 50%; background: #deded9; font-weight: 900; color: #777; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 38px; height: 38px; }
.avatar-lg { width: 74px; height: 74px; font-size: 24px; }
.avatar-xl { width: 104px; height: 104px; font-size: 34px; }

.me-layout { display: grid; grid-template-columns: 310px 1fr; gap: 22px; }
.profile-summary { padding: 24px; align-self: start; }
.profile-summary .avatar { margin-bottom: 17px; }
.profile-summary h1 { display: flex; align-items: center; gap: 7px; margin: 0; font-size: 26px; }
.profile-summary .bio { color: var(--muted); line-height: 1.55; }
.profile-details { display: grid; gap: 8px; padding: 16px 0; margin: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 14px; }
.profile-details div { display: flex; justify-content: space-between; gap: 10px; }
.profile-actions { display: grid; gap: 8px; }
.content-card { padding: 22px; }
.content-tabs { display: flex; gap: 4px; margin-bottom: 18px; padding: 4px; border-radius: 13px; background: var(--soft); }
.content-tabs button { flex: 1; min-height: 38px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; cursor: pointer; font-weight: 700; }
.content-tabs button.is-active { color: var(--primary-dark); background: #fff; box-shadow: 0 2px 8px rgba(127,42,72,.08); }
.post-card { padding: 18px 0; border-bottom: 1px solid var(--line); }
.post-card:first-child { padding-top: 0; }
.post-card:last-child { border-bottom: 0; }
.post-head { display: flex; align-items: center; gap: 10px; }
.post-head > .button { margin-left: auto; }
.post-author { font-weight: 800; }
.post-time { color: var(--muted); font-size: 12px; }
.post-text { margin: 13px 0; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-images { display: grid; grid-template-columns: repeat(3,1fr); gap: 5px; border-radius: 14px; overflow: hidden; }
.post-images img { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--soft); }
.user-list { display: grid; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: #fafaf8; }
.user-row-info { flex: 1; min-width: 0; }
.user-row-name { display: flex; align-items: center; gap: 6px; font-weight: 800; }
.user-row-bio { margin-top: 3px; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.profile-page { max-width: 820px; margin: auto; }
.profile-hero { padding: 30px; }
.profile-hero-top { display: flex; align-items: center; gap: 20px; }
.profile-hero h1 { display: flex; align-items: center; gap: 8px; margin: 0; }
.profile-hero .bio { margin: 20px 0; line-height: 1.6; color: var(--muted); }
.profile-hero-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.profile-posts { margin-top: 18px; padding: 22px; }
.locked-posts { padding: 40px; text-align: center; color: var(--muted); }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(4px); }
.modal-card { position: relative; z-index: 1; width: min(100%, 480px); max-height: calc(100vh - 40px); overflow-y: auto; padding: 28px; border-radius: 24px; background: #fff; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 36px 5px 0; letter-spacing: -.03em; }
.modal-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.modal-close { position: absolute; top: 15px; right: 15px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--soft); cursor: pointer; font-size: 20px; }
.modal-logo { margin-bottom: 18px; }
.segmented { display: flex; padding: 4px; margin: 20px 0 16px; border-radius: 13px; background: var(--soft); }
.segmented button { flex: 1; height: 39px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-weight: 750; }
.segmented button.is-active { background: #fff; }
.field { display: grid; gap: 7px; margin: 14px 0; font-size: 13px; font-weight: 700; }
.field input, .field select, .field textarea, .message-form textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; outline: none; background: #fff; color: var(--ink); font-weight: 500;
}
.field input:focus, .field select:focus, .field textarea:focus, .message-form textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(244,81,122,.12); }
.code-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profile-form-card { width: min(100%, 560px); }
.avatar-editor { display: flex; align-items: center; gap: 18px; margin: 20px 0; }
.image-previews { display: grid; grid-template-columns: repeat(5,1fr); gap: 7px; margin: 12px 0; }
.image-previews img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 9px; }
.language-list { display: grid; gap: 7px; margin-top: 18px; }
.language-list button { padding: 13px; border: 1px solid var(--line); border-radius: 12px; text-align: left; background: #fff; cursor: pointer; }
.language-list button.is-active { color: #fff; background: var(--primary); border-color: var(--primary); }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: min(90vw,460px); padding: 12px 17px; border-radius: 12px; color: #fff; background: var(--primary-dark); box-shadow: var(--shadow); text-align: center; font-size: 14px; }

@media (max-width: 760px) {
  body { padding-bottom: calc(67px + env(safe-area-inset-bottom)); }
  .social-topbar { height: 58px; }
  .social-topbar-inner { grid-template-columns: auto 1fr auto; padding: 0 14px; }
  .social-brand { font-size: 17px; }
  .desktop-nav { display: none; }
  .top-actions { gap: 7px; }
  .avatar-button { width: 35px; height: 35px; }
  .language-button { min-width: 38px; height: 34px; }
  .back-button:not([hidden]) { display: grid; margin-right: 8px; }
  .social-main { min-height: calc(100vh - 125px); padding: 16px 14px 26px; }
  .mobile-tabs {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(3,1fr); height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(16px);
  }
  .mobile-tabs a { position: relative; display: grid; place-content: center; justify-items: center; gap: 3px; color: #929292; font-size: 11px; font-weight: 700; }
  .mobile-tabs a.is-active { color: var(--primary); }
  .mobile-tabs svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .tab-icon-wrap { position: relative; }
  .mobile-tabs .nav-badge { top: -7px; right: -10px; }
  .page-head { margin-bottom: 15px; }
  .page-head h1 { font-size: 28px; }
  .match-shell { min-height: calc(100vh - 181px); }
  .match-stage { width: min(100%, 370px); }
  .match-card { border-radius: 23px; aspect-ratio: .78; }
  .match-info { padding: 22px; }
  .match-name { font-size: 26px; }
  .match-actions { margin-top: 16px; }
  .swipe-button { width: 56px; height: 56px; }
  .chats-layout, .me-layout { display: block; min-height: auto; }
  .chat-placeholder { display: none; }
  .list-panel { border: 0; background: transparent; }
  .list-panel-head { padding: 4px 2px 16px; }
  .friends-strip, .thread-list { background: #fff; }
  .friends-strip { border: 1px solid var(--line); border-radius: 18px 18px 0 0; }
  .thread-list { border: 1px solid var(--line); border-radius: 0 0 18px 18px; overflow: hidden; }
  .thread-list:only-child { border-radius: 18px; }
  .chat-page { margin: -16px -14px -26px; }
  .chat-card { height: calc(100vh - 58px); min-height: 0; border: 0; border-radius: 0; }
  .chat-head { padding: 10px 13px; }
  .messages { padding: 15px 12px; }
  .message-bubble { max-width: 84%; }
  .message-form { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  body.route-chat { padding-bottom: 0; }
  body.route-chat .mobile-tabs { display: none; }
  .profile-summary { margin-bottom: 14px; }
  .content-card { padding: 17px; }
  .profile-hero { padding: 22px; }
  .profile-hero-top { align-items: flex-start; }
  .post-images { grid-template-columns: repeat(2,1fr); }
  .modal { align-items: end; padding: 0; }
  .modal-card { width: 100%; max-height: 92vh; padding: 24px 20px calc(22px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
