/* ================================================================
   ChatMatch v2 — Main Stylesheet
   Mobile-first, Facebook-inspired, dark/light theme
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ---- Variables ---- */
:root {
   --bg: #18191a;
   --bg2: #242526;
   --bg3: #3a3b3c;
   --card: #242526;
   --border: #3e4042;
   --text: #e4e6eb;
   --text2: #b0b3b8;
   --primary: #1877f2;
   --primary-h: #1466d1;
   --primary-light: rgba(24,119,242,0.15);
   --primary-rgb: 24,119,242;
   --green: #42b72a;
   --green-light: rgba(66,183,42,0.15);
   --red: #f02849;
   --red-light: rgba(240,40,73,0.15);
   --gold: #f59e0b;
   --purple: #8b5cf6;
   --radius: 12px;
   --radius-sm: 8px;
   --radius-xs: 6px;
   --shadow: 0 2px 12px rgba(0, 0, 0, .5);
   --shadow-lg: 0 8px 32px rgba(0,0,0,.6);
   --topbar-h: 56px;
   --nav-h: 56px;
   --trans: .18s ease;
   --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
   /* Skeleton shimmer */
   --shimmer-from: rgba(255,255,255,.04);
   --shimmer-to: rgba(255,255,255,.1);
}

[data-theme="light"] {
   --bg: #f0f2f5;
   --bg2: #ffffff;
   --bg3: #e4e6eb;
   --card: #ffffff;
   --border: #dddfe2;
   --text: #050505;
   --text2: #65676b;
   --shadow: 0 2px 8px rgba(0, 0, 0, .12);
   --shadow-lg: 0 8px 24px rgba(0,0,0,.18);
   --shimmer-from: rgba(0,0,0,.04);
   --shimmer-to: rgba(0,0,0,.08);
}

/* ---- Reset ---- */
*,
*::before,
*::after {
   box-sizing: border-box;
   margin: 0;
   padding: 0
}

html {
   scroll-behavior: smooth;
   -webkit-text-size-adjust: 100%
}

body {
   font-family: var(--font);
   background: var(--bg);
   color: var(--text);
   font-size: 15px;
   line-height: 1.5;
   padding-top: var(--topbar-h);
   padding-bottom: var(--nav-h);
   min-height: 100vh;
   overscroll-behavior-y: none
}

a {
   color: var(--primary);
   text-decoration: none
}

a:hover {
   text-decoration: underline
}

img {
   display: block;
   max-width: 100%
}

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

button {
   cursor: pointer;
   background: none;
   border: none
}

::-webkit-scrollbar {
   width: 6px;
   height: 6px
}

::-webkit-scrollbar-track {
   background: transparent
}

::-webkit-scrollbar-thumb {
   background: var(--border);
   border-radius: 3px
}

/* ================================================================
   TOPBAR
   ================================================================ */
.topbar {
   position: fixed;
   top: 0;
   left: 0;
   right: 0;
   height: var(--topbar-h);
   background: var(--card);
   border-bottom: 1px solid var(--border);
   display: flex;
   align-items: center;
   gap: .75rem;
   padding: 0 1rem;
   z-index: 200;
   backdrop-filter: blur(12px)
}

.topbar-logo {
   font-size: 1.5rem;
   font-weight: 700;
   color: var(--text);
   white-space: nowrap;
   text-decoration: none;
   flex-shrink: 0
}

.logo-text {
   display: none
}

@media(min-width:500px) {
   .logo-text {
      display: inline
   }
}

.topbar-search {
   flex: 1;
   max-width: 280px;
   position: relative
}

.topbar-search input {
   width: 100%;
   background: var(--bg3);
   border: none;
   border-radius: 20px;
   padding: .45rem 1rem;
   color: var(--text);
   outline: none;
   font-size: .9rem
}

.search-results {
   position: absolute;
   top: calc(100% + 6px);
   left: 0;
   right: 0;
   background: var(--card);
   border: 1px solid var(--border);
   border-radius: var(--radius);
   box-shadow: var(--shadow);
   overflow: hidden;
   z-index: 300
}

.search-result-item {
   display: flex;
   align-items: center;
   gap: .6rem;
   padding: .6rem 1rem;
   cursor: pointer
}

.search-result-item:hover {
   background: var(--bg3)
}

.topbar-right {
   display: flex;
   align-items: center;
   gap: .25rem;
   margin-left: auto
}

.topbar-btn {
   position: relative;
   padding: .5rem;
   border-radius: 50%;
   color: var(--text);
   transition: background var(--trans);
   display: flex
}

.topbar-btn:hover {
   background: var(--bg3)
}

.topbar-avatar img {
   border-radius: 50%;
   width: 36px;
   height: 36px;
   object-fit: cover
}

.badge {
   position: absolute;
   top: -2px;
   right: -2px;
   background: var(--red);
   color: #fff;
   font-size: .7rem;
   font-weight: 700;
   min-width: 18px;
   height: 18px;
   border-radius: 9px;
   display: flex;
   align-items: center;
   justify-content: center;
   padding: 0 4px;
   border: 2px solid var(--card)
}

/* Notification panel */
.notif-panel {
   position: fixed;
   top: var(--topbar-h);
   right: 0;
   width: min(380px, 100vw);
   max-height: calc(100vh - var(--topbar-h));
   background: var(--card);
   border-left: 1px solid var(--border);
   overflow-y: auto;
   z-index: 190;
   box-shadow: var(--shadow);
   transform: translateX(100%);
   transition: transform var(--trans)
}

.notif-panel.open {
   transform: none
}

.notif-backdrop {
   display: none;
   position: fixed;
   inset: 0;
   z-index: 180
}

.notif-panel.open~.notif-backdrop {
   display: block
}

.notif-panel-head {
   display: flex;
   align-items: center;
   justify-content: space-between;
   padding: .75rem 1rem;
   border-bottom: 1px solid var(--border);
   position: sticky;
   top: 0;
   background: var(--card)
}

.notif-panel-head h4 {
   font-size: 1.1rem;
   font-weight: 700
}

.notif-item {
   display: flex;
   align-items: flex-start;
   gap: .75rem;
   padding: .75rem 1rem;
   border-bottom: 1px solid var(--border);
   text-decoration: none;
   color: var(--text);
   transition: background var(--trans)
}

.notif-item:hover {
   background: var(--bg3)
}

.notif-item.unread {
   background: rgba(24, 119, 242, .1)
}

.notif-text {
   flex: 1;
   font-size: .875rem;
   line-height: 1.4
}

.notif-time {
   font-size: .75rem;
   color: var(--text2);
   white-space: nowrap
}

.notif-loading {
   padding: 1.5rem;
   text-align: center;
   color: var(--text2);
   font-size: .9rem
}

/* ================================================================
   BOTTOM NAV
   ================================================================ */
.bottom-nav {
   position: fixed;
   bottom: 0;
   left: 0;
   right: 0;
   height: var(--nav-h);
   background: var(--card);
   border-top: 1px solid var(--border);
   display: flex;
   z-index: 200;
   backdrop-filter: blur(12px)
}

.nav-item {
   flex: 1;
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: center;
   color: var(--text2);
   gap: 2px;
   position: relative;
   text-decoration: none;
   font-size: .65rem;
   font-weight: 500;
   transition: color var(--trans);
   padding: .3rem 0
}

.nav-item:hover,
.nav-item.active {
   color: var(--primary)
}

.nav-icon {
   font-size: 1.4rem;
   line-height: 1
}

.nav-post {
   flex: 1;
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: center;
   color: var(--text2);
   gap: 2px;
   font-size: .65rem;
   font-weight: 500;
   border: none;
   background: none;
   cursor: pointer
}

.nav-post-icon {
   display: flex;
   align-items: center;
   justify-content: center;
   width: 42px;
   height: 42px;
   background: var(--primary);
   border-radius: 50%;
   color: #fff;
   font-size: 1.3rem;
   box-shadow: 0 2px 8px rgba(24, 119, 242, .5)
}

.nav-unread {
   position: absolute;
   top: 4px;
   right: calc(50% - 22px);
   background: var(--red);
   color: #fff;
   font-size: .65rem;
   font-weight: 700;
   padding: 1px 5px;
   border-radius: 8px
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn-primary {
   display: inline-flex;
   align-items: center;
   justify-content: center;
   gap: .4rem;
   background: var(--primary);
   color: #fff;
   border: none;
   border-radius: var(--radius-sm);
   padding: .55rem 1.1rem;
   font-weight: 600;
   cursor: pointer;
   transition: background var(--trans);
   text-decoration: none
}

.btn-primary:hover {
   background: var(--primary-h);
   text-decoration: none;
   color: #fff
}

.btn-outline {
   display: inline-flex;
   align-items: center;
   justify-content: center;
   gap: .4rem;
   background: transparent;
   color: var(--text);
   border: 1px solid var(--border);
   border-radius: var(--radius-sm);
   padding: .55rem 1.1rem;
   font-weight: 600;
   cursor: pointer;
   transition: all var(--trans);
   text-decoration: none
}

.btn-outline:hover {
   background: var(--bg3);
   text-decoration: none
}

.btn-block {
   width: 100%
}

.btn-sm {
   padding: .35rem .75rem;
   font-size: .85rem
}

.btn-link {
   background: none;
   border: none;
   color: var(--primary);
   cursor: pointer;
   font-size: .85rem;
   font-weight: 600
}

/* ================================================================
   FORMS
   ================================================================ */
.form-field {
   display: flex;
   flex-direction: column;
   gap: .3rem
}

.form-field label {
   font-size: .85rem;
   font-weight: 600;
   color: var(--text2)
}

.form-field input,
.form-field select,
.form-field textarea {
   background: var(--bg3);
   border: 1.5px solid var(--border);
   border-radius: var(--radius-sm);
   color: var(--text);
   padding: .6rem .85rem;
   outline: none;
   transition: border var(--trans);
   width: 100%
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
   border-color: var(--primary)
}

.form-row {
   display: grid;
   grid-template-columns: 1fr 1fr;
   gap: .75rem
}

@media(max-width:480px) {
   .form-row {
      grid-template-columns: 1fr
   }
}

.form-hint {
   font-size: .78rem;
   color: var(--text2)
}

.pw-wrap {
   position: relative
}

.pw-wrap input {
   padding-right: 2.5rem
}

.pw-toggle {
   position: absolute;
   right: .5rem;
   top: 50%;
   transform: translateY(-50%);
   background: none;
   border: none;
   cursor: pointer;
   padding: .2rem;
   color: var(--text2)
}

.alert {
   padding: .75rem 1rem;
   border-radius: var(--radius-sm);
   font-size: .9rem;
   margin-bottom: .75rem
}

.alert-error {
   background: rgba(240, 40, 73, .15);
   border: 1px solid var(--red);
   color: #f85149
}

/* ================================================================
   AUTH
   ================================================================ */
.auth-page {
   display: flex;
   align-items: center;
   justify-content: center;
   min-height: 100vh;
   padding: 1rem;
   background: var(--bg)
}

body:has(.auth-page) {
   padding: 0
}

.auth-card {
   background: var(--card);
   border: 1px solid var(--border);
   border-radius: var(--radius);
   padding: 2rem;
   width: min(440px, 100%);
   box-shadow: var(--shadow)
}

.auth-card-wide {
   width: min(620px, 100%)
}

.auth-logo {
   text-align: center;
   margin-bottom: 1.5rem
}

.auth-logo-icon {
   font-size: 3rem;
   display: block
}

.auth-logo h1 {
   font-size: 1.9rem;
   font-weight: 700;
   margin: .25rem 0
}

.auth-logo p {
   color: var(--text2);
   font-size: .9rem
}

.auth-form {
   display: flex;
   flex-direction: column;
   gap: .85rem
}

.auth-switch {
   text-align: center;
   margin-top: 1rem;
   font-size: .9rem;
   color: var(--text2)
}

/* Tags picker */
.tag-picker {
   display: flex;
   flex-wrap: wrap;
   gap: .4rem;
   margin-top: .25rem
}

.tag-chip {
   cursor: pointer
}

.tag-chip input {
   display: none
}

.tag-chip span {
   display: inline-block;
   padding: .3rem .7rem;
   border: 1.5px solid var(--border);
   border-radius: 20px;
   font-size: .8rem;
   transition: all var(--trans)
}

.tag-chip input:checked+span {
   background: var(--primary);
   border-color: var(--primary);
   color: #fff
}

.tag-chip-sm {
   display: inline-block;
   padding: .2rem .55rem;
   background: var(--bg3);
   border: 1px solid var(--border);
   border-radius: 20px;
   font-size: .75rem;
   color: var(--text2)
}

/* ================================================================
   LAYOUT
   ================================================================ */
.app-main {
   max-width: 680px;
   margin: 0 auto;
   padding: 1rem;
   display: flex;
   flex-direction: column;
   gap: .75rem
}

/* ================================================================
   TOPBAR SEARCH
   ================================================================ */

/* ================================================================
   FEED
   ================================================================ */
.composer-trigger-card {
   background: var(--card);
   border: 1px solid var(--border);
   border-radius: var(--radius);
   padding: .75rem 1rem;
   display: flex;
   flex-direction: column;
   gap: .65rem
}

.composer-trigger-card>.avatar-md,
.composer-trigger-card>div:first-child {
   flex-shrink: 0
}

.composer-trigger-card>div:first-child {
   display: flex;
   align-items: center;
   gap: .65rem
}

.composer-placeholder {
   flex: 1;
   background: var(--bg3);
   border: none;
   border-radius: 20px;
   padding: .55rem 1rem;
   color: var(--text2);
   text-align: left;
   cursor: pointer;
   font-size: .95rem;
   transition: background var(--trans)
}

.composer-placeholder:hover {
   background: var(--border)
}

.quick-media-row {
   border-top: 1px solid var(--border);
   padding-top: .5rem;
   display: flex
}

.quick-media-btn {
   display: flex;
   align-items: center;
   gap: .4rem;
   color: var(--text2);
   font-size: .85rem;
   font-weight: 600;
   cursor: pointer;
   padding: .3rem .5rem;
   border-radius: var(--radius-xs);
   transition: background var(--trans)
}

.quick-media-btn:hover {
   background: var(--bg3)
}

.feed-tabs {
   display: flex;
   background: var(--card);
   border: 1px solid var(--border);
   border-radius: var(--radius);
   overflow: hidden
}

.feed-tab {
   flex: 1;
   padding: .65rem;
   text-align: center;
   color: var(--text2);
   font-weight: 600;
   font-size: .9rem;
   transition: all var(--trans);
   text-decoration: none
}

.feed-tab:hover {
   background: var(--bg3);
   color: var(--text);
   text-decoration: none
}

.feed-tab.active {
   background: var(--primary);
   color: #fff
}

/* ================================================================
   POST CARD
   ================================================================ */
.post-card {
   background: var(--card);
   border: 1px solid var(--border);
   border-radius: var(--radius);
   overflow: hidden
}

.post-head {
   display: flex;
   align-items: flex-start;
   gap: .75rem;
   padding: .85rem 1rem .5rem
}

.post-avatar-link img {
   border-radius: 50%;
   flex-shrink: 0
}

.post-meta {
   flex: 1;
   min-width: 0
}

.post-author-name {
   font-weight: 700;
   color: var(--text);
   font-size: .95rem;
   display: inline-flex;
   align-items: center;
   gap: .3rem
}

.post-author-name:hover {
   text-decoration: underline
}

.post-meta-row {
   display: flex;
   align-items: center;
   gap: .4rem;
   font-size: .78rem;
   color: var(--text2)
}

.post-vis {
   font-size: .72rem
}

.post-menu-wrap {
   position: relative;
   flex-shrink: 0
}

.post-menu-btn {
   padding: .4rem;
   border-radius: 50%;
   color: var(--text2);
   display: flex;
   transition: background var(--trans)
}

.post-menu-btn:hover {
   background: var(--bg3)
}

.post-menu {
   position: absolute;
   top: calc(100% + 4px);
   right: 0;
   background: var(--card);
   border: 1px solid var(--border);
   border-radius: var(--radius-sm);
   box-shadow: var(--shadow);
   z-index: 50;
   min-width: 160px;
   overflow: hidden
}

.post-menu button {
   display: block;
   width: 100%;
   padding: .65rem 1rem;
   text-align: left;
   color: var(--text);
   font-size: .9rem;
   transition: background var(--trans)
}

.post-menu button:hover {
   background: var(--bg3)
}

.post-content {
   padding: .25rem 1rem .7rem;
   font-size: .975rem;
   line-height: 1.6;
   word-break: break-word
}

/* Photo grid */
.post-photos {
   display: grid;
   gap: 2px;
   max-height: 500px;
   overflow: hidden
}

.post-photos-1 {
   grid-template-columns: 1fr
}

.post-photos-1 .photo-cell {
   max-height: 500px
}

.post-photos-2 {
   grid-template-columns: 1fr 1fr
}

.post-photos-3 {
   grid-template-columns: 1fr 1fr;
   grid-template-rows: 200px 200px
}

.post-photos-3 .photo-cell:first-child {
   grid-row: span 2
}

.post-photos-4 {
   grid-template-columns: 1fr 1fr;
   grid-template-rows: 200px 200px
}

.post-photos-5 {
   grid-template-columns: 1fr 1fr 1fr;
   grid-template-rows: 180px 180px
}

.post-photos-5 .photo-cell:nth-child(1),
.post-photos-5 .photo-cell:nth-child(2) {
   grid-column: span 1;
   grid-row: 1
}

.photo-cell {
   position: relative;
   overflow: hidden;
   cursor: zoom-in;
   background: var(--bg3)
}

.photo-cell img {
   width: 100%;
   height: 100%;
   object-fit: cover;
   transition: opacity var(--trans)
}

.photo-cell:hover img {
   opacity: .92
}

.photo-more {
   position: relative
}

.photo-more-count {
   position: absolute;
   inset: 0;
   background: rgba(0, 0, 0, .55);
   display: flex;
   align-items: center;
   justify-content: center;
   color: #fff;
   font-size: 1.8rem;
   font-weight: 700
}

.post-video-wrap {
   position: relative;
   background: #000
}

.post-video {
   width: 100%;
   max-height: 400px;
   display: block
}

.post-counts {
   display: flex;
   justify-content: space-between;
   align-items: center;
   padding: .4rem 1rem;
   font-size: .85rem;
   color: var(--text2)
}

.post-actions {
   display: flex;
   border-top: 1px solid var(--border)
}

.post-action-btn {
   flex: 1;
   display: flex;
   align-items: center;
   justify-content: center;
   gap: .4rem;
   padding: .6rem;
   color: var(--text2);
   font-weight: 600;
   font-size: .88rem;
   border-radius: 0;
   transition: background var(--trans)
}

.post-action-btn:hover {
   background: var(--bg3);
   color: var(--text)
}

.post-action-btn svg {
   flex-shrink: 0
}

/* Reaction picker */
.reaction-picker {
   position: fixed;
   background: var(--card);
   border: 1px solid var(--border);
   border-radius: 30px;
   padding: .4rem .6rem;
   display: flex;
   gap: .1rem;
   box-shadow: var(--shadow);
   z-index: 300;
   transition: opacity var(--trans)
}

.reaction-btn {
   background: none;
   border: none;
   font-size: 1.7rem;
   cursor: pointer;
   border-radius: 50%;
   padding: .2rem;
   transition: transform .15s ease
}

.reaction-btn:hover {
   transform: scale(1.5) translateY(-4px)
}

/* Comments */
.comments-section {
   border-top: 1px solid var(--border)
}

.comments-list {
   padding: .5rem 1rem 0
}

.comment-item {
   display: flex;
   gap: .6rem;
   margin-bottom: .65rem
}

.comment-bubble {
   background: var(--bg3);
   border-radius: 18px;
   padding: .5rem .85rem;
   flex: 1;
   max-width: 90%
}

.comment-author-name {
   font-weight: 700;
   font-size: .85rem
}

.comment-text {
   font-size: .9rem;
   line-height: 1.5;
   word-break: break-word
}

.comment-actions {
   display: flex;
   gap: .75rem;
   padding: .15rem 0 0 .5rem;
   font-size: .75rem;
   color: var(--text2)
}

.comment-actions button {
   background: none;
   border: none;
   cursor: pointer;
   color: var(--text2);
   font-size: .75rem;
   font-weight: 600;
   padding: 0;
   transition: color var(--trans)
}

.comment-actions button:hover {
   color: var(--text)
}

.replies {
   margin-left: 2.5rem;
   margin-top: .4rem
}

.comment-compose {
   display: flex;
   align-items: center;
   gap: .6rem;
   padding: .65rem 1rem;
   border-top: 1px solid var(--border)
}

.comment-input-wrap {
   flex: 1;
   display: flex;
   align-items: center;
   background: var(--bg3);
   border-radius: 20px;
   padding: .3rem .3rem .3rem .85rem
}

.comment-input {
   flex: 1;
   background: none;
   border: none;
   outline: none;
   font-size: .9rem;
   color: var(--text)
}

.comment-send-btn {
   background: none;
   border: none;
   cursor: pointer;
   color: var(--primary);
   font-size: 1.1rem;
   padding: .2rem .4rem;
   flex-shrink: 0
}

.comments-loading {
   padding: 1rem;
   text-align: center;
   color: var(--text2);
   font-size: .85rem
}

/* ================================================================
   COMPOSER MODAL
   ================================================================ */
.modal-overlay {
   position: fixed;
   inset: 0;
   background: rgba(0, 0, 0, .7);
   z-index: 400;
   display: flex;
   align-items: center;
   justify-content: center;
   backdrop-filter: blur(4px);
   padding: 1rem
}

.modal-box,
.composer-box {
   background: var(--card);
   border-radius: var(--radius);
   width: min(540px, 100%);
   max-height: 90vh;
   overflow-y: auto;
   box-shadow: var(--shadow)
}

.composer-header,
.modal-header {
   display: flex;
   align-items: center;
   justify-content: space-between;
   padding: 1rem 1.25rem;
   border-bottom: 1px solid var(--border);
   position: sticky;
   top: 0;
   background: var(--card);
   z-index: 1
}

.composer-header h3,
.modal-header h3 {
   font-size: 1.1rem;
   font-weight: 700
}

.modal-close {
   background: none;
   border: none;
   cursor: pointer;
   color: var(--text2);
   font-size: 1.25rem;
   padding: .25rem .4rem;
   border-radius: 50%;
   line-height: 1;
   transition: background var(--trans)
}

.modal-close:hover {
   background: var(--bg3)
}

.composer-user-row {
   display: flex;
   align-items: center;
   gap: .75rem;
   padding: .9rem 1.25rem .5rem
}

.vis-select {
   background: var(--bg3);
   border: 1px solid var(--border);
   border-radius: 6px;
   padding: .25rem .5rem;
   font-size: .8rem;
   outline: none;
   color: var(--text)
}

.composer-textarea {
   width: 100%;
   border: none;
   background: transparent;
   color: var(--text);
   outline: none;
   resize: none;
   padding: .5rem 1.25rem;
   font-size: 1rem;
   line-height: 1.6;
   min-height: 90px;
   max-height: 240px
}

.media-preview-area {
   display: flex;
   flex-wrap: wrap;
   gap: .4rem;
   padding: .5rem 1.25rem
}

.media-preview-item {
   position: relative;
   width: 80px;
   height: 80px;
   border-radius: var(--radius-xs);
   overflow: hidden
}

.media-preview-item img {
   width: 100%;
   height: 100%;
   object-fit: cover
}

.media-preview-remove {
   position: absolute;
   top: 2px;
   right: 2px;
   background: rgba(0, 0, 0, .65);
   color: #fff;
   border: none;
   border-radius: 50%;
   width: 20px;
   height: 20px;
   font-size: .75rem;
   cursor: pointer;
   display: flex;
   align-items: center;
   justify-content: center
}

.remove-media-btn {
   background: none;
   border: none;
   cursor: pointer;
   color: var(--red);
   font-size: .8rem;
   padding: .25rem;
   display: block;
   margin-top: .25rem
}

.composer-toolbar {
   display: flex;
   align-items: center;
   flex-wrap: wrap;
   gap: .25rem;
   padding: .75rem 1.25rem;
   border-top: 1px solid var(--border)
}

.composer-tool {
   display: flex;
   align-items: center;
   gap: .35rem;
   color: var(--text2);
   font-size: .85rem;
   font-weight: 600;
   cursor: pointer;
   padding: .4rem .6rem;
   border-radius: var(--radius-xs);
   transition: background var(--trans)
}

.composer-tool:hover {
   background: var(--bg3);
   color: var(--text)
}

.composer-submit {
   margin-left: auto;
   padding: .5rem 1.25rem
}

/* ================================================================
   DISCOVER
   ================================================================ */
.discover-main {
   max-width: 500px
}

.filter-panel {
   background: var(--card);
   border: 1px solid var(--border);
   border-radius: var(--radius);
   padding: .75rem 1rem
}

.filter-toggle {
   cursor: pointer;
   font-weight: 600;
   font-size: .9rem;
   list-style: none;
   display: flex;
   align-items: center;
   gap: .5rem
}

.filter-toggle::-webkit-details-marker {
   display: none
}

.filter-badge {
   font-weight: 400;
   color: var(--text2);
   font-size: .8rem
}

.filter-form {
   margin-top: .75rem
}

.filter-row {
   display: flex;
   flex-wrap: wrap;
   gap: .5rem;
   align-items: flex-end
}

.filter-row label {
   display: flex;
   flex-direction: column;
   gap: .2rem;
   font-size: .8rem;
   font-weight: 600;
   color: var(--text2)
}

.filter-row select,
.filter-row input {
   background: var(--bg3);
   border: 1px solid var(--border);
   border-radius: var(--radius-xs);
   padding: .35rem .6rem;
   color: var(--text);
   outline: none;
   font-size: .85rem
}

.filter-row input[type=number] {
   width: 70px
}

/* Card stack */
.card-stack-wrap {
   display: flex;
   flex-direction: column;
   align-items: center;
   gap: 1rem
}

.card-stack {
   position: relative;
   width: min(380px, 94vw);
   height: 540px
}

.disc-card {
   position: absolute;
   inset: 0;
   background: var(--card);
   border-radius: 20px;
   overflow: hidden;
   box-shadow: 0 4px 24px rgba(0, 0, 0, .4);
   cursor: grab;
   user-select: none;
   touch-action: pan-y;
   transform-origin: bottom center
}

.disc-card:active {
   cursor: grabbing
}

.disc-photos {
   position: relative;
   height: 360px;
   background: var(--bg3);
   overflow: hidden
}

.disc-photo {
   width: 100%;
   height: 100%;
   object-fit: cover;
   position: absolute;
   inset: 0;
   opacity: 0;
   transition: opacity .2s
}

.disc-photo.active {
   opacity: 1
}

.disc-no-photo {
   height: 100%;
   display: flex;
   align-items: center;
   justify-content: center;
   font-size: 5rem
}

.disc-dots {
   position: absolute;
   top: .5rem;
   left: 50%;
   transform: translateX(-50%);
   display: flex;
   gap: 4px;
   z-index: 2
}

.disc-dot {
   width: 30px;
   height: 3px;
   border-radius: 2px;
   background: rgba(255, 255, 255, .4)
}

.disc-dot.active {
   background: #fff
}

.disc-tap-prev,
.disc-tap-next {
   position: absolute;
   top: 0;
   bottom: 0;
   width: 40%;
   z-index: 3
}

.disc-tap-prev {
   left: 0
}

.disc-tap-next {
   right: 0
}

.swipe-label {
   position: absolute;
   top: 1.5rem;
   padding: .3rem .8rem;
   border: 3px solid;
   border-radius: 8px;
   font-size: 1.4rem;
   font-weight: 800;
   opacity: 0;
   text-transform: uppercase;
   letter-spacing: 1px;
   pointer-events: none;
   z-index: 4
}

.like-lbl {
   left: 1rem;
   color: #42b72a;
   border-color: #42b72a
}

.nope-lbl {
   right: 1rem;
   color: var(--red);
   border-color: var(--red)
}

.disc-info {
   padding: .8rem 1rem
}

.disc-name-row {
   display: flex;
   align-items: center;
   gap: .4rem;
   flex-wrap: wrap
}

.disc-name {
   font-size: 1.2rem;
   font-weight: 700
}

.disc-age {
   font-size: 1rem;
   color: var(--text2)
}

.disc-sub {
   font-size: .82rem;
   color: var(--text2);
   display: flex;
   gap: .6rem;
   margin: .15rem 0 .3rem
}

.disc-bio {
   font-size: .85rem;
   color: var(--text2);
   margin-bottom: .35rem;
   overflow: hidden;
   display: -webkit-box;
   -webkit-line-clamp: 2;
   -webkit-box-orient: vertical
}

.disc-tags {
   display: flex;
   flex-wrap: wrap;
   gap: .3rem
}

.disc-actions {
   display: flex;
   align-items: center;
   justify-content: center;
   gap: 1.25rem
}

.disc-btn {
   width: 58px;
   height: 58px;
   border-radius: 50%;
   border: none;
   cursor: pointer;
   font-size: 1.5rem;
   display: flex;
   align-items: center;
   justify-content: center;
   box-shadow: 0 2px 12px rgba(0, 0, 0, .3);
   transition: transform .15s, box-shadow .15s
}

.disc-btn:hover {
   transform: scale(1.1);
   box-shadow: 0 4px 20px rgba(0, 0, 0, .4)
}

.disc-nope {
   background: #fff;
   color: var(--red);
   border: 2px solid #ffd0d8
}

.disc-like {
   background: #fff;
   color: #42b72a;
   border: 2px solid #c6f0bc
}

.disc-info-btn {
   background: var(--bg3);
   color: var(--text2);
   width: 46px;
   height: 46px;
   font-size: 1.2rem
}

/* Match modal */
.match-box {
   background: linear-gradient(135deg, var(--primary), #6f42c1);
   border-radius: 20px;
   padding: 2.5rem 2rem;
   text-align: center;
   color: #fff;
   width: min(340px, 90vw)
}

.match-confetti {
   font-size: 3rem;
   margin-bottom: .5rem
}

.match-title {
   font-size: 2rem;
   font-weight: 800
}

.match-sub {
   margin: .5rem 0 1.5rem;
   opacity: .9
}

.match-avatars {
   display: flex;
   align-items: center;
   justify-content: center;
   gap: .75rem;
   margin-bottom: 1.5rem
}

.match-av {
   width: 75px;
   height: 75px;
   border-radius: 50%;
   border: 3px solid #fff;
   object-fit: cover
}

.match-heart {
   font-size: 2.5rem;
   animation: heartbeat 1s ease-in-out infinite
}

@keyframes heartbeat {

   0%,
   100% {
      transform: scale(1)
   }

   50% {
      transform: scale(1.2)
   }
}

.match-btns {
   display: flex;
   gap: .75rem;
   justify-content: center;
   flex-wrap: wrap
}

.match-btns .btn-outline {
   border-color: rgba(255, 255, 255, .5);
   color: #fff
}

/* Matches strip */
.matches-strip {
   background: var(--card);
   border: 1px solid var(--border);
   border-radius: var(--radius);
   padding: .75rem 1rem;
   width: 100%
}

.strip-title {
   font-size: .9rem;
   font-weight: 700;
   margin-bottom: .65rem
}

.matches-scroll {
   display: flex;
   gap: .75rem;
   overflow-x: auto;
   padding-bottom: .25rem
}

.matches-scroll::-webkit-scrollbar {
   height: 4px
}

.match-avatar-item {
   display: flex;
   flex-direction: column;
   align-items: center;
   gap: .3rem;
   flex-shrink: 0;
   text-decoration: none
}

.match-av-wrap {
   position: relative
}

.match-name {
   font-size: .72rem;
   color: var(--text2);
   max-width: 56px;
   text-align: center;
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis
}

/* ================================================================
   CHAT
   ================================================================ */
body:has(.chat-layout) {
   padding-top: 0
}

/* ค้นหาบรรทัดที่ประมาณ 695 */
.chat-layout {
   display: flex;
   /* แก้ไขจาก 100vh เป็น calc ด้านล่างนี้ */
   height: calc(100vh - var(--nav-h)); 
   max-width: 1100px;
   margin: 0 auto;
   overflow: hidden;
}

.chat-layout.chat-open .conv-sidebar {
   display: none
}

@media(min-width:768px) {
   .chat-layout.chat-open .conv-sidebar {
      display: flex;
      flex-direction: column
   }
}

/* ค้นหาบรรทัดที่ประมาณ 713 */
.conv-sidebar {
   width: 340px;
   flex-shrink: 0;
   border-right: 1px solid var(--border);
   background: var(--card);
   display: flex;
   flex-direction: column;
   height: 100%; /* เปลี่ยนจาก 100vh เป็น 100% */
   overflow: hidden
}

.conv-sidebar-head {
   padding: 1rem;
   border-bottom: 1px solid var(--border);
   display: flex;
   align-items: center;
   justify-content: space-between;
   flex-shrink: 0;
   padding-top: 1rem; /* ปรับตามความเหมาะสม */
}

.conv-sidebar-head h2 {
   font-size: 1.2rem;
   font-weight: 700
}

.conv-list {
   flex: 1;
   overflow-y: auto
}

.conv-item {
   display: flex;
   align-items: center;
   gap: .75rem;
   padding: .8rem 1rem;
   border-bottom: 1px solid var(--border);
   color: var(--text);
   text-decoration: none;
   transition: background var(--trans);
   position: relative
}

.conv-item:hover {
   background: var(--bg3)
}

.conv-item.active {
   background: rgba(24, 119, 242, .1)
}

.conv-av-wrap {
   position: relative;
   flex-shrink: 0
}

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

.conv-name {
   font-weight: 700;
   font-size: .9rem;
   display: flex;
   align-items: center;
   gap: .3rem
}

.conv-preview {
   font-size: .82rem;
   color: var(--text2);
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis
}

.conv-meta {
   display: flex;
   flex-direction: column;
   align-items: flex-end;
   gap: .3rem;
   flex-shrink: 0
}

.conv-time {
   font-size: .72rem;
   color: var(--text2)
}

.conv-unread {
   background: var(--primary);
   color: #fff;
   font-size: .7rem;
   font-weight: 700;
   min-width: 20px;
   height: 20px;
   border-radius: 10px;
   display: flex;
   align-items: center;
   justify-content: center;
   padding: 0 5px
}

.empty-conv {
   padding: 2rem 1rem;
   text-align: center;
   color: var(--text2)
}

/* ค้นหาบรรทัดที่ประมาณ 791 */
.chat-window {
   flex: 1;
   display: flex;
   flex-direction: column;
   height: 100%; /* เปลี่ยนจาก 100vh เป็น 100% */
   overflow: hidden;
   background: var(--bg)
}
.chat-header {
   display: flex;
   align-items: center;
   gap: .75rem;
   padding: .75rem 1rem;
   background: var(--card);
   border-bottom: 1px solid var(--border);
   flex-shrink: 0;
   /* padding-top: calc(var(--topbar-h) + .75rem) */
}

@media(min-width:768px) {
   .chat-header {
      /* ถ้าบน Desktop มี Topbar ให้บวก Padding เพิ่ม */
      padding-top: 0.75rem; 
   }
}

.chat-back {
   font-size: 1.6rem;
   color: var(--text2);
   line-height: 1;
   text-decoration: none;
   margin-right: .25rem
}

@media(min-width:768px) {
   .chat-back {
      display: none
   }
}

.chat-header-info {
   display: flex;
   align-items: center;
   gap: .7rem;
   flex: 1;
   text-decoration: none;
   color: var(--text)
}

.chat-status-text {
   font-size: .78rem;
   color: var(--text2)
}

.chat-messages {
   flex: 1;
   overflow-y: auto;
   padding: 1rem;
   display: flex;
   flex-direction: column;
   gap: .4rem
}

.msg-row {
   display: flex;
   align-items: flex-end;
   gap: .45rem
}

.msg-mine {
   flex-direction: row-reverse
}

.msg-bubble {
   max-width: 72%;
   border-radius: 18px;
   padding: .55rem .9rem;
   word-break: break-word
}

.bubble-mine {
   background: var(--primary);
   color: #fff;
   border-bottom-right-radius: 4px
}

.bubble-theirs {
   background: var(--card);
   border-bottom-left-radius: 4px;
   border: 1px solid var(--border)
}

.msg-text {
   display: block;
   line-height: 1.5;
   font-size: .95rem
}

.msg-img {
   max-width: 240px;
   border-radius: 12px;
   cursor: zoom-in
}

.msg-sticker {
   font-size: 2.5rem;
   display: block;
   line-height: 1
}

.msg-meta {
   display: flex;
   align-items: center;
   gap: .3rem;
   margin-top: .2rem;
   font-size: .68rem;
   opacity: .7;
   justify-content: flex-end
}

.msg-mine .msg-meta {
   color: rgba(255, 255, 255, .8)
}

.msg-read {
   font-size: .7rem
}

.sticker-panel {
   border-top: 1px solid var(--border);
   background: var(--card);
   padding: .5rem
}

.sticker-grid {
   display: flex;
   flex-wrap: wrap;
   gap: .25rem;
   max-height: 140px;
   overflow-y: auto
}

.sticker-btn {
   background: none;
   border: none;
   cursor: pointer;
   font-size: 1.8rem;
   padding: .3rem;
   border-radius: 8px;
   transition: background var(--trans);
   line-height: 1
}

.sticker-btn:hover {
   background: var(--bg3)
}

.chat-input-bar {
   display: flex;
   align-items: center;
   gap: .4rem;
   padding: .65rem .85rem;
   background: var(--card);
   border-top: 1px solid var(--border);
   flex-shrink: 0;
   padding-bottom: calc(.65rem + env(safe-area-inset-bottom))
}

.chat-tool-btn {
   padding: .45rem;
   border-radius: 50%;
   color: var(--text2);
   display: flex;
   flex-shrink: 0;
   transition: background var(--trans)
}

.chat-tool-btn:hover {
   background: var(--bg3)
}

.msg-input {
   flex: 1;
   background: var(--bg3);
   border: none;
   border-radius: 20px;
   padding: .5rem 1rem;
   color: var(--text);
   outline: none;
   font-size: .95rem
}

.chat-send-btn {
   background: var(--primary);
   color: #fff;
   border: none;
   border-radius: 50%;
   width: 38px;
   height: 38px;
   display: flex;
   align-items: center;
   justify-content: center;
   flex-shrink: 0;
   transition: background var(--trans)
}

.chat-send-btn:hover {
   background: var(--primary-h)
}

.chat-empty {
   flex: 1;
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: center;
   color: var(--text2);
   gap: .5rem
}

.hidden-mobile {
   display: none !important
}

@media(min-width:768px) {
   .hidden-mobile {
      display: flex !important
   }
}

/* ================================================================
   PROFILE
   ================================================================ */
.profile-main {
   max-width: 860px;
   padding: 0;
   gap: 0
}

.profile-cover-wrap {
   position: relative;
   margin-bottom: 60px
}

.profile-cover {
   height: 220px;
   background: linear-gradient(135deg, var(--primary), #6f42c1);
   background-size: cover;
   background-position: center;
   position: relative
}

.cover-edit-btn {
   position: absolute;
   bottom: .75rem;
   right: .75rem;
   background: rgba(0, 0, 0, .55);
   color: #fff;
   padding: .4rem .8rem;
   border-radius: var(--radius-xs);
   cursor: pointer;
   font-size: .85rem
}

.profile-av-wrap {
   position: absolute;
   bottom: -55px;
   left: 1.5rem
}

.profile-avatar {
   width: 108px;
   height: 108px;
   border-radius: 50%;
   border: 4px solid var(--bg);
   object-fit: cover;
   display: block
}

.verified-badge-lg {
   position: absolute;
   bottom: 4px;
   right: 4px;
   background: var(--primary);
   color: #fff;
   width: 28px;
   height: 28px;
   border-radius: 50%;
   display: flex;
   align-items: center;
   justify-content: center;
   font-size: .9rem;
   font-weight: 700;
   border: 2px solid var(--bg)
}

.avatar-cam-btn {
   position: absolute;
   bottom: 6px;
   right: 6px;
   background: var(--bg3);
   color: var(--text);
   width: 28px;
   height: 28px;
   border-radius: 50%;
   display: flex;
   align-items: center;
   justify-content: center;
   cursor: pointer;
   font-size: .85rem;
   border: 2px solid var(--card)
}

.profile-info-card {
   background: var(--card);
   border-bottom: 1px solid var(--border);
   padding: 1rem 1.5rem 1.25rem
}

.profile-name-row {
   display: flex;
   justify-content: space-between;
   align-items: flex-start;
   margin-bottom: .5rem;
   flex-wrap: wrap;
   gap: .5rem
}

.profile-actions-col {
   display: flex;
   align-items: center;
   gap: .5rem;
   flex-wrap: wrap
}

.profile-name {
   font-size: 1.5rem;
   font-weight: 800;
   display: flex;
   align-items: center;
   gap: .4rem;
   flex-wrap: wrap
}

.profile-age {
   font-size: 1.1rem;
   font-weight: 400;
   color: var(--text2)
}

.profile-username {
   font-size: .88rem;
   color: var(--text2)
}

.profile-location {
   font-size: .88rem;
   color: var(--text2);
   margin-top: .15rem
}

.profile-joined {
   font-size: .78rem;
   color: var(--text2);
   margin-top: .15rem
}

.profile-bio {
   font-size: .95rem;
   line-height: 1.6;
   margin: .6rem 0;
   color: var(--text)
}

.profile-tags {
   display: flex;
   flex-wrap: wrap;
   gap: .35rem;
   margin: .5rem 0
}

.profile-status {
   font-size: .85rem;
   margin-top: .4rem
}

.status-online {
   color: #42b72a;
   font-weight: 600
}

.status-offline {
   color: var(--text2)
}

.profile-stats {
   display: flex;
   gap: 1.5rem;
   margin-top: .75rem;
   border-top: 1px solid var(--border);
   padding-top: .75rem
}

.stat-item {
   display: flex;
   flex-direction: column;
   align-items: center;
   gap: .1rem
}

.stat-item strong {
   font-size: 1.1rem;
   font-weight: 700
}

.stat-item span {
   font-size: .78rem;
   color: var(--text2)
}

.dark-toggle-label {
   display: flex;
   align-items: center;
   gap: .4rem;
   cursor: pointer
}

.dark-toggle-input {
   display: none
}

.dark-toggle-track {
   width: 38px;
   height: 22px;
   background: var(--border);
   border-radius: 11px;
   position: relative;
   transition: background var(--trans)
}

.dark-toggle-input:checked+.dark-toggle-track {
   background: var(--primary)
}

.dark-toggle-thumb {
   position: absolute;
   top: 2px;
   left: 2px;
   width: 18px;
   height: 18px;
   background: #fff;
   border-radius: 50%;
   transition: transform var(--trans)
}

.dark-toggle-input:checked+.dark-toggle-track .dark-toggle-thumb {
   transform: translateX(16px)
}

.profile-section {
   background: var(--card);
   border-bottom: 1px solid var(--border);
   padding: 1rem 1.5rem
}

.section-head {
   display: flex;
   align-items: center;
   justify-content: space-between;
   margin-bottom: .85rem
}

.section-head h3 {
   font-size: 1rem;
   font-weight: 700
}

/* Photo grid (profile) */
.photo-grid {
   display: grid;
   grid-template-columns: repeat(3, 1fr);
   gap: .4rem
}

.photo-grid-item {
   position: relative;
   aspect-ratio: 1;
   border-radius: var(--radius-xs);
   overflow: hidden;
   background: var(--bg3)
}

.photo-grid-item img {
   width: 100%;
   height: 100%;
   object-fit: cover;
   cursor: zoom-in;
   transition: opacity var(--trans)
}

.photo-grid-item:hover img {
   opacity: .9
}

.photo-delete-btn {
   position: absolute;
   top: 4px;
   right: 4px;
   background: rgba(0, 0, 0, .65);
   color: #fff;
   border: none;
   border-radius: 50%;
   width: 22px;
   height: 22px;
   font-size: .75rem;
   cursor: pointer;
   display: none;
   align-items: center;
   justify-content: center
}

.photo-grid-item:hover .photo-delete-btn {
   display: flex
}

.photo-grid-empty {
   grid-column: 1/-1;
   text-align: center;
   padding: 2rem;
   color: var(--text2)
}

/* Edit modal */
.edit-form {
   padding: 1rem 1.25rem;
   display: flex;
   flex-direction: column;
   gap: .85rem
}

/* Verified badge (inline) */
.verified-badge {
   display: inline-flex;
   align-items: center;
   justify-content: center;
   background: var(--primary);
   color: #fff;
   width: 16px;
   height: 16px;
   border-radius: 50%;
   font-size: .62rem;
   font-weight: 700;
   flex-shrink: 0
}

/* Online dot */
.online-dot {
   position: absolute;
   bottom: 1px;
   right: 1px;
   width: 11px;
   height: 11px;
   background: #42b72a;
   border-radius: 50%;
   border: 2px solid var(--card)
}

/* Avatars */
.avatar-xs {
   width: 28px;
   height: 28px;
   border-radius: 50%;
   object-fit: cover;
   flex-shrink: 0
}

.avatar-sm {
   width: 38px;
   height: 38px;
   border-radius: 50%;
   object-fit: cover;
   flex-shrink: 0
}

.avatar-md {
   width: 44px;
   height: 44px;
   border-radius: 50%;
   object-fit: cover;
   flex-shrink: 0
}

/* ================================================================
   LIGHTBOX
   ================================================================ */
.lightbox {
   position: fixed;
   inset: 0;
   background: rgba(0, 0, 0, .92);
   z-index: 500;
   display: flex;
   align-items: center;
   justify-content: center
}

.lb-img-wrap {
   max-width: 92vw;
   max-height: 90vh
}

.lb-img-wrap img {
   max-width: 92vw;
   max-height: 90vh;
   border-radius: 8px;
   object-fit: contain
}

.lb-close {
   position: absolute;
   top: 1rem;
   right: 1rem;
   color: #fff;
   font-size: 1.8rem;
   background: rgba(255, 255, 255, .15);
   border: none;
   border-radius: 50%;
   width: 42px;
   height: 42px;
   cursor: pointer;
   display: flex;
   align-items: center;
   justify-content: center
}

.lb-prev,
.lb-next {
   position: absolute;
   top: 50%;
   transform: translateY(-50%);
   color: #fff;
   font-size: 2.5rem;
   background: rgba(255, 255, 255, .15);
   border: none;
   width: 48px;
   height: 48px;
   border-radius: 50%;
   cursor: pointer;
   display: flex;
   align-items: center;
   justify-content: center
}

.lb-prev {
   left: 1rem
}

.lb-next {
   right: 1rem
}

.lb-counter {
   position: absolute;
   bottom: 1rem;
   left: 50%;
   transform: translateX(-50%);
   color: #fff;
   font-size: .85rem;
   background: rgba(0, 0, 0, .5);
   padding: .3rem .8rem;
   border-radius: 20px
}

/* ================================================================
   ADMIN
   ================================================================ */
.admin-wrap {
   max-width: 900px;
   margin: 0 auto;
   padding: 1.5rem
}

.admin-table {
   width: 100%;
   border-collapse: collapse;
   background: var(--card);
   border-radius: var(--radius);
   overflow: hidden
}

.admin-table th,
.admin-table td {
   padding: .7rem 1rem;
   text-align: left;
   border-bottom: 1px solid var(--border)
}

.admin-table th {
   font-size: .82rem;
   color: var(--text2);
   font-weight: 600
}

/* ================================================================
   EMPTY STATES & MISC
   ================================================================ */
.empty-feed {
   background: var(--card);
   border: 1px solid var(--border);
   border-radius: var(--radius);
   padding: 3rem 1.5rem;
   text-align: center
}

.empty-icon {
   font-size: 3.5rem;
   margin-bottom: .75rem
}

.empty-feed h3 {
   font-size: 1.1rem;
   margin-bottom: .35rem
}

.empty-feed p {
   color: var(--text2);
   font-size: .9rem;
   margin-bottom: 1rem
}

.spinner {
   width: 28px;
   height: 28px;
   border: 3px solid var(--border);
   border-top-color: var(--primary);
   border-radius: 50%;
   animation: spin .8s linear infinite;
   margin: 0 auto
}

@keyframes spin {
   to {
      transform: rotate(360deg)
   }
}

/* Animations */
@keyframes fadeIn {
   from {
      opacity: 0;
      transform: translateY(10px)
   }

   to {
      opacity: 1;
      transform: translateY(0)
   }
}

.post-card {
   animation: fadeIn .25s ease both
}

.crop-modal-box {
   background: var(--card);
   padding: 20px;
   border-radius: 16px;
   box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.crop-container {
   background: #f0f0f0;
   border-radius: 8px;
   overflow: hidden;
}

.crop-controls button {
   width: 40px;
   height: 40px;
   border-radius: 50%;
   border: 1px solid #ccc;
   background: white;
   font-size: 20px;
   cursor: pointer;
   transition: all 0.2s;
}

.crop-controls button:hover {
   background: #f0f0f0;
}

/* ═══════════════════════════════════════════════
   NOTIFICATION PANEL — Facebook/X-quality UI
   ═══════════════════════════════════════════════ */

/* Overlay backdrop */
#notifOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
  z-index: 1099;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#notifOverlay.show {
  opacity: 1;
  pointer-events: all;
}

/* Notification Panel */
#notifPanel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  max-width: 100vw;
  height: 100dvh;
  background: var(--card);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,0.18);
  transform: translateX(110%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
#notifPanel.open {
  transform: translateX(0);
}

/* Panel Header */
.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 2;
}
.notif-panel-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.notif-panel-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.notif-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 20px;
  transition: background 0.15s;
  white-space: nowrap;
}
.notif-action-btn:hover {
  background: var(--primary-light);
}
.notif-close-btn {
  width: 34px;
  height: 34px;
  background: var(--bg2);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.15s;
  flex-shrink: 0;
}
.notif-close-btn:hover {
  background: var(--border);
}

/* Settings toggle row */
.notif-push-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.notif-push-bar span {
  font-size: 0.82rem;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 6px;
}
/* iOS-style Toggle */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-track {
  background: var(--primary);
}
.toggle-switch input:checked + .toggle-track::before {
  transform: translateX(20px);
}

/* Filter tabs */
.notif-filter-tabs {
  display: flex;
  padding: 0.5rem 1.25rem;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.notif-filter-tabs::-webkit-scrollbar { display: none; }
.notif-filter-tab {
  padding: 5px 14px;
  border-radius: 20px;
  border: none;
  background: var(--bg2);
  color: var(--text2);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.notif-filter-tab.active {
  background: var(--primary-light);
  color: var(--primary);
}

/* Notification List */
#notifList {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.25rem 0;
  scroll-behavior: smooth;
}
#notifList::-webkit-scrollbar {
  width: 4px;
}
#notifList::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Notif Item */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
  border-bottom: 1px solid transparent;
  text-decoration: none;
  color: inherit;
}
.notif-item:hover {
  background: var(--bg);
}
.notif-item.unread {
  background: color-mix(in srgb, var(--primary) 6%, var(--card));
}
.notif-item.unread:hover {
  background: color-mix(in srgb, var(--primary) 10%, var(--card));
}

/* Unread dot */
.notif-item.unread::after {
  content: '';
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  width: 9px;
  height: 9px;
  background: var(--primary);
  border-radius: 50%;
  flex-shrink: 0;
}

/* Avatar wrapper with type icon badge */
.notif-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.notif-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.notif-type-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--card);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
}

/* Notif text */
.notif-content {
  flex: 1;
  min-width: 0;
}
.notif-text {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 3px;
  word-break: break-word;
}
.notif-text strong {
  font-weight: 700;
  color: var(--text);
}
.notif-time {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
}
.notif-item:not(.unread) .notif-time {
  color: var(--text2);
  font-weight: 500;
}

/* Thumbnail preview (optional) */
.notif-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg2);
}

/* Empty & loading states */
.notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  gap: 0.75rem;
  color: var(--text2);
}
.notif-empty-icon {
  font-size: 3rem;
  line-height: 1;
}
.notif-empty h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.notif-empty p {
  font-size: 0.85rem;
  margin: 0;
}

.notif-skeleton {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 0.75rem 1.25rem;
}
.skel {
  background: var(--bg2);
  border-radius: 4px;
  animation: skelPulse 1.4s ease-in-out infinite;
}
@keyframes skelPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.skel-circle { width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; }
.skel-line-lg { height: 13px; width: 80%; margin-bottom: 6px; }
.skel-line-sm { height: 11px; width: 50%; }

/* ─── Push Permission Banner (inline in feed) ───────────────────── */
#push-prompt {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: white;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
  animation: slideDown 0.5s ease;
}
@keyframes slideDown {
  from { transform: translateY(-14px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
.push-prompt-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.push-prompt-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.push-prompt-text {
  font-size: 0.85rem;
  line-height: 1.35;
}
.push-prompt-text strong {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
}
.push-prompt-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.push-btn-enable {
  background: white;
  color: var(--primary);
  border: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.push-btn-enable:hover { opacity: 0.88; }
.push-btn-dismiss {
  background: rgba(255,255,255,0.18);
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}
.push-btn-dismiss:hover { background: rgba(255,255,255,0.28); }

/* ─── Toast notification (top-right popup) ──────────────────────── */
#notifToastContainer {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.notif-toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 340px;
  pointer-events: all;
  cursor: pointer;
  animation: toastIn 0.35s cubic-bezier(0.4,0,0.2,1) forwards;
  transform-origin: top right;
}
@keyframes toastIn {
  from { transform: scale(0.85) translateX(20px); opacity: 0; }
  to   { transform: scale(1) translateX(0);        opacity: 1; }
}
.notif-toast.hiding {
  animation: toastOut 0.25s ease forwards;
}
@keyframes toastOut {
  to { transform: scale(0.85) translateX(20px); opacity: 0; }
}
.notif-toast img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.notif-toast-body strong {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}
.notif-toast-body span {
  font-size: 0.78rem;
  color: var(--text2);
}
/* ================================================================
   VIP SYSTEM — Global Styles
   ================================================================ */

/* VIP Badges */
.vip-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .3px;
  vertical-align: middle;
}
.vip-badge-sm {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 5px;
  border-radius: 10px;
  font-size: .62rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .2px;
  vertical-align: middle;
}

/* VIP Profile ring */
.vip-premium-ring .avatar-md,
.vip-premium-ring .avatar-sm,
.vip-premium-ring .avatar-lg {
  box-shadow: 0 0 0 3px #f59e0b, 0 0 0 5px rgba(245,158,11,.25) !important;
}
.vip-plus-ring .avatar-md,
.vip-plus-ring .avatar-sm {
  box-shadow: 0 0 0 3px #3b82f6, 0 0 0 5px rgba(59,130,246,.25) !important;
}

/* Boosted profile glow */
.is-boosted-card {
  position: relative;
}
.is-boosted-card::before {
  content: '🚀 Boosted';
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  background: linear-gradient(135deg,#f59e0b,#ef4444);
  color: #fff;
  font-size: .68rem;
  font-weight: 800;
  padding: .18rem .55rem;
  border-radius: 20px;
}

/* Super Like button on swipe cards */
.super-like-btn {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(99,102,241,.4);
  transition: transform .2s, box-shadow .2s;
}
.super-like-btn:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(99,102,241,.55); }
.super-like-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* Blurred likes (Basic tier) */
.blurred-like {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
  position: relative;
}
.likes-blur-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font-weight: 700;
  color: var(--text);
}

/* Swipe limit banner */
.swipe-limit-banner {
  background: linear-gradient(135deg, #f59e0b22, #ef444422);
  border: 1.5px solid #f59e0b55;
  border-radius: 14px;
  padding: .85rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
}
.swipe-limit-icon { font-size: 1.5rem; }
.swipe-limit-text { flex: 1; font-size: .88rem; }
.swipe-limit-title { font-weight: 700; margin-bottom: 2px; }
.swipe-limit-sub   { color: var(--text2); font-size: .78rem; }
.swipe-limit-cta {
  background: linear-gradient(135deg,#f59e0b,#ef4444);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .45rem .9rem;
  font-weight: 800;
  font-size: .8rem;
  cursor: pointer;
  white-space: nowrap;
}

/* Credits chip in topbar/profile */
.credits-topbar-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: linear-gradient(135deg,#f59e0b,#d97706);
  color: #fff;
  border-radius: 20px;
  padding: .2rem .55rem;
  font-size: .75rem;
  font-weight: 800;
}

/* ================================================================
   NEW SYSTEMS — Upload Progress, Skeleton Posts, Tinder Swipe,
   Stories Bar, Match Animations, Performance Polish
   ================================================================ */

/* ----------------------------------------------------------------
   SKELETON SHIMMER — Base animation
   ---------------------------------------------------------------- */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}
.skeleton-base {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--shimmer-from) 37%, var(--bg3) 63%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 8px;
}

/* ----------------------------------------------------------------
   SKELETON POST CARD — Facebook-style while uploading
   ---------------------------------------------------------------- */
.post-skeleton {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  will-change: opacity;
  animation: skeletonFadeIn .25s ease;
}
@keyframes skeletonFadeIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:none; } }
.post-skeleton .sk-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .85rem;
}
.post-skeleton .sk-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg3);
  background: linear-gradient(90deg, var(--bg3) 25%, var(--shimmer-from) 37%, var(--bg3) 63%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
}
.post-skeleton .sk-lines { flex: 1; display: flex; flex-direction: column; gap: .45rem; }
.post-skeleton .sk-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg3) 25%, var(--shimmer-from) 37%, var(--bg3) 63%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
}
.post-skeleton .sk-line.short { width: 60%; }
.post-skeleton .sk-img {
  height: 220px;
  border-radius: var(--radius-sm);
  margin: .5rem 0 .85rem;
  background: linear-gradient(90deg, var(--bg3) 25%, var(--shimmer-from) 37%, var(--bg3) 63%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
}
.post-skeleton .sk-actions {
  display: flex;
  gap: .5rem;
  border-top: 1px solid var(--border);
  padding-top: .85rem;
}
.post-skeleton .sk-btn {
  flex: 1; height: 32px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--bg3) 25%, var(--shimmer-from) 37%, var(--bg3) 63%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
}

/* ----------------------------------------------------------------
   UPLOAD PROGRESS BAR — Facebook-style top bar + card progress
   ---------------------------------------------------------------- */
#uploadProgressBar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  background: linear-gradient(90deg, #1877f2, #42b72a, #1877f2);
  background-size: 200% 100%;
  animation: progressShine 1.2s linear infinite;
  z-index: 99999;
  transition: width .15s ease, opacity .3s ease;
  box-shadow: 0 0 8px rgba(24,119,242,.6);
  border-radius: 0 2px 2px 0;
}
@keyframes progressShine {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* In-card upload progress overlay */
.upload-progress-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  gap: 1rem;
  backdrop-filter: blur(2px);
}
.upload-progress-ring {
  position: relative;
  width: 64px; height: 64px;
}
.upload-progress-ring svg { transform: rotate(-90deg); }
.upload-progress-ring .ring-track { stroke: rgba(255,255,255,.2); fill: none; stroke-width: 5; }
.upload-progress-ring .ring-fill  { stroke: #fff; fill: none; stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 175; stroke-dashoffset: 175; transition: stroke-dashoffset .2s ease; }
.upload-progress-pct {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: .85rem;
}
.upload-progress-label {
  color: #fff; font-size: .85rem; font-weight: 600;
  background: rgba(0,0,0,.5); padding: .35rem .8rem; border-radius: 20px;
}

/* ----------------------------------------------------------------
   FEED END INDICATOR
   ---------------------------------------------------------------- */
#feedEnd {
  display: none;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text2);
  font-size: .88rem;
}
#feedEnd::before {
  content: '';
  display: block;
  width: 48px; height: 2px;
  background: var(--border);
  margin: 0 auto 1rem;
  border-radius: 2px;
}

/* ----------------------------------------------------------------
   STORIES BAR (Instagram/Facebook style)
   ---------------------------------------------------------------- */
.stories-bar {
  display: flex;
  gap: .75rem;
  overflow-x: auto;
  padding: .75rem 1rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
.stories-bar::-webkit-scrollbar { display: none; }
.story-item {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .35rem;
  cursor: pointer;
  scroll-snap-align: start;
  user-select: none;
}
.story-ring {
  width: 62px; height: 62px;
  border-radius: 50%;
  padding: 2.5px;
  background: linear-gradient(135deg, #f59e0b, #ef4444, #8b5cf6, #1877f2);
  transition: transform var(--trans);
}
.story-ring:hover { transform: scale(1.06); }
.story-ring.seen {
  background: var(--border);
}
.story-ring-inner {
  width: 100%; height: 100%;
  border-radius: 50%;
  overflow: hidden;
  border: 2.5px solid var(--card);
  background: var(--bg3);
}
.story-ring-inner img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.story-add-btn {
  width: 62px; height: 62px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  color: var(--primary);
  background: var(--bg);
  transition: all var(--trans);
  cursor: pointer;
  flex-shrink: 0;
}
.story-add-btn:hover { background: var(--primary-light); border-color: var(--primary); }
.story-name {
  font-size: .7rem;
  color: var(--text2);
  max-width: 62px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

/* Story viewer overlay */
.story-viewer {
  position: fixed; inset: 0;
  background: #000;
  z-index: 10000;
  display: flex; flex-direction: column;
  display: none;
}
.story-progress-bars {
  display: flex; gap: 3px;
  padding: .75rem .75rem .35rem;
  position: relative; z-index: 2;
}
.story-prog-seg {
  flex: 1; height: 3px;
  background: rgba(255,255,255,.35);
  border-radius: 2px;
  overflow: hidden;
}
.story-prog-fill {
  height: 100%;
  background: #fff;
  width: 0%;
  transition: width linear;
}
.story-prog-fill.done { width: 100%; }
.story-header {
  display: flex; align-items: center;
  gap: .75rem; padding: .5rem .75rem;
  position: relative; z-index: 2;
}
.story-header img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.story-header-info { flex: 1; }
.story-header-name { color: #fff; font-weight: 700; font-size: .95rem; }
.story-header-time { color: rgba(255,255,255,.7); font-size: .78rem; }
.story-close-btn {
  color: #fff; font-size: 1.5rem; background: none; border: none;
  padding: .25rem .5rem; cursor: pointer; line-height: 1;
}
.story-media {
  flex: 1; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.story-media img, .story-media video {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
}
.story-tap-prev, .story-tap-next {
  position: absolute; top: 0; bottom: 0; width: 40%;
  cursor: pointer; z-index: 3;
}
.story-tap-prev { left: 0; }
.story-tap-next { right: 0; }
.story-caption {
  padding: 1rem .75rem;
  color: #fff; font-size: .95rem;
  text-shadow: 0 1px 4px rgba(0,0,0,.8);
  position: relative; z-index: 2;
}

/* ----------------------------------------------------------------
   TINDER SWIPE CARDS — Premium Redesign
   ---------------------------------------------------------------- */
.disc-card {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  overflow: hidden;
  cursor: grab;
  will-change: transform;
  touch-action: none;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  background: var(--card);
  transform-origin: center bottom;
  user-select: none;
  -webkit-user-select: none;
}
.disc-card:active { cursor: grabbing; }

/* Stacked cards depth effect */
#cardStack { position: relative; height: 520px; perspective: 1000px; }
.disc-card:nth-last-child(2) {
  transform: scale(0.96) translateY(10px);
  filter: brightness(.85);
  pointer-events: none;
}
.disc-card:nth-last-child(3) {
  transform: scale(0.92) translateY(20px);
  filter: brightness(.7);
  pointer-events: none;
}

/* Photos inside card */
.disc-photos { position: absolute; inset: 0; }
.disc-photo {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  display: none;
}
.disc-photo.active { display: block; }

/* Photo gradient bottom */
.disc-photo::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 65%;
  background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.4) 50%, transparent 100%);
}

/* Photo tap zones */
.disc-photo-tap-l, .disc-photo-tap-r {
  position: absolute; top: 0; bottom: 0; width: 35%; z-index: 5;
}
.disc-photo-tap-l { left: 0; }
.disc-photo-tap-r { right: 0; }

/* Dot indicators */
.disc-dots {
  position: absolute; top: .75rem; left: 0; right: 0;
  display: flex; justify-content: center; gap: 5px; z-index: 6;
}
.disc-dot {
  height: 3px; flex: 1; max-width: 40px;
  background: rgba(255,255,255,.4); border-radius: 2px;
  transition: background .2s;
}
.disc-dot.active { background: #fff; }

/* Card info overlay */
.disc-info {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 1.2rem 1.1rem 1rem;
  z-index: 7;
  pointer-events: none;
}
.disc-name {
  color: #fff; font-weight: 800; font-size: 1.5rem;
  line-height: 1.2; text-shadow: 0 2px 8px rgba(0,0,0,.5);
  display: flex; align-items: center; gap: .5rem;
}
.disc-age { font-weight: 400; font-size: 1.2rem; opacity: .9; }
.disc-distance {
  color: rgba(255,255,255,.85); font-size: .85rem;
  margin-top: .25rem; display: flex; align-items: center; gap: .3rem;
}
.disc-bio {
  color: rgba(255,255,255,.8); font-size: .88rem;
  margin-top: .4rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.disc-tags {
  display: flex; flex-wrap: wrap; gap: .35rem;
  margin-top: .6rem; pointer-events: none;
}
.disc-tag {
  background: rgba(255,255,255,.18);
  backdrop-filter: blur(8px);
  color: #fff; font-size: .75rem; font-weight: 600;
  padding: .25rem .7rem; border-radius: 20px;
  border: 1px solid rgba(255,255,255,.25);
}

/* LIKE / NOPE / SUPER LIKE labels */
.swipe-label {
  position: absolute; z-index: 10;
  font-size: 2rem; font-weight: 900;
  border-width: 4px; border-style: solid;
  padding: .3rem .9rem; border-radius: 12px;
  opacity: 0; pointer-events: none;
  letter-spacing: .05em;
  text-shadow: 0 2px 8px rgba(0,0,0,.2);
  transform: rotate(-15deg);
}
.like-lbl {
  top: 1.5rem; left: 1.2rem;
  color: #42b72a; border-color: #42b72a;
  transform: rotate(-15deg);
  text-transform: uppercase;
}
.nope-lbl {
  top: 1.5rem; right: 1.2rem;
  color: #ef4444; border-color: #ef4444;
  transform: rotate(15deg);
  text-transform: uppercase;
}
.super-lbl {
  bottom: 5rem; left: 50%; transform: translateX(-50%) rotate(0deg);
  color: #3b82f6; border-color: #3b82f6;
  text-transform: uppercase; font-size: 1.6rem;
}

/* Action buttons row */
.disc-actions {
  display: flex; justify-content: center;
  align-items: center; gap: 1rem;
  padding: .75rem 1rem;
  margin-top: auto;
}
.disc-btn {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  flex-shrink: 0;
}
.disc-btn:active { transform: scale(.92) !important; }
.disc-btn-rewind {
  width: 48px; height: 48px;
  background: var(--card);
  color: #f59e0b;
  box-shadow: 0 2px 12px rgba(245,158,11,.35);
  border: 2px solid rgba(245,158,11,.3);
  font-size: 1.2rem;
}
.disc-btn-nope {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 4px 20px rgba(239,68,68,.45);
  font-size: 1.6rem;
}
.disc-btn-super {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  box-shadow: 0 4px 16px rgba(59,130,246,.45);
  font-size: 1.2rem;
}
.disc-btn-like {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #42b72a, #22c55e);
  color: #fff;
  box-shadow: 0 4px 20px rgba(66,183,42,.45);
  font-size: 1.6rem;
}
.disc-btn-info {
  width: 48px; height: 48px;
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 2px 12px rgba(24,119,242,.25);
  border: 2px solid rgba(24,119,242,.3);
  font-size: 1.2rem;
}
.disc-btn:hover { transform: scale(1.08); }
.disc-btn-like:hover  { box-shadow: 0 6px 28px rgba(66,183,42,.6); }
.disc-btn-nope:hover  { box-shadow: 0 6px 28px rgba(239,68,68,.6); }
.disc-btn-super:hover { box-shadow: 0 6px 24px rgba(59,130,246,.6); }

/* Super like burst animation */
@keyframes superBurst {
  0%   { transform: scale(1); opacity: 1; }
  50%  { transform: scale(1.4); opacity: .7; }
  100% { transform: scale(0); opacity: 0; }
}
.super-burst {
  position: fixed; pointer-events: none; z-index: 20000;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,.8), transparent 70%);
  animation: superBurst .5s ease forwards;
  transform-origin: center;
}

/* Match modal — full screen celebration */
#matchModal {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, rgba(24,119,242,.92), rgba(139,92,246,.92));
  z-index: 20000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  text-align: center;
  padding: 2rem;
}
@keyframes matchPop {
  0%   { transform: scale(0) rotate(-10deg); opacity: 0; }
  60%  { transform: scale(1.12) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}
.match-emoji { font-size: 4rem; animation: matchPop .5s .1s ease both; }
.match-title {
  font-size: 2.2rem; font-weight: 900; color: #fff;
  animation: matchPop .5s .2s ease both;
  text-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.match-sub { color: rgba(255,255,255,.85); font-size: 1rem; animation: matchPop .5s .3s ease both; }
.match-avatars {
  display: flex; align-items: center; gap: 1rem;
  animation: matchPop .5s .4s ease both;
}
.match-av {
  width: 90px; height: 90px; border-radius: 50%;
  object-fit: cover;
  border: 3px solid #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.match-heart { font-size: 2rem; animation: pulse 1s ease infinite; }
.match-actions { display: flex; gap: 1rem; animation: matchPop .5s .5s ease both; }
.match-btn-chat {
  background: #fff; color: var(--primary);
  border: none; border-radius: 25px;
  padding: .8rem 2rem; font-weight: 800; font-size: 1rem;
  cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.2);
  transition: transform .15s;
}
.match-btn-chat:hover { transform: scale(1.04); }
.match-btn-skip {
  background: rgba(255,255,255,.2); color: #fff;
  border: 2px solid rgba(255,255,255,.4); border-radius: 25px;
  padding: .8rem 2rem; font-weight: 700; font-size: 1rem;
  cursor: pointer; backdrop-filter: blur(8px);
  transition: background .2s;
}
.match-btn-skip:hover { background: rgba(255,255,255,.3); }

/* Confetti particles */
.confetti-piece {
  position: fixed;
  width: 10px; height: 10px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 19999;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ----------------------------------------------------------------
   MATCH CARD GRID (Matches section)
   ---------------------------------------------------------------- */
.matches-scroll {
  display: flex; gap: .75rem;
  overflow-x: auto; padding: .5rem 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.matches-scroll::-webkit-scrollbar { display: none; }
.match-mini {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center;
  gap: .4rem; cursor: pointer;
  text-decoration: none; color: inherit;
}
.match-mini-av {
  width: 64px; height: 64px; border-radius: 50%;
  object-fit: cover;
  border: 3px solid transparent;
  background: linear-gradient(var(--card), var(--card)) padding-box,
              linear-gradient(135deg, #1877f2, #a855f7) border-box;
  box-shadow: 0 2px 12px rgba(24,119,242,.3);
  transition: transform .2s;
}
.match-mini:hover .match-mini-av { transform: scale(1.08); }
.match-mini-name {
  font-size: .73rem; font-weight: 600;
  max-width: 68px; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text2);
}
.match-mini-badge {
  position: relative;
}
.match-mini-badge::after {
  content: '';
  position: absolute; bottom: 2px; right: 2px;
  width: 14px; height: 14px;
  background: var(--green);
  border-radius: 50%;
  border: 2px solid var(--card);
}

/* ----------------------------------------------------------------
   IMPROVED POST CARD — Media skeleton & lazy load
   ---------------------------------------------------------------- */
.media-skeleton {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--bg3) 25%, var(--shimmer-from) 37%, var(--bg3) 63%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: inherit;
  z-index: 1;
  transition: opacity .3s ease;
}
.lazy-img.loaded + .media-skeleton,
.lazy-img.loaded ~ .media-skeleton { opacity: 0; pointer-events: none; }
.photo-cell { position: relative; overflow: hidden; }
.lazy-img { position: relative; z-index: 2; opacity: 0; transition: opacity .35s ease; }
.lazy-img.loaded { opacity: 1; }

/* ----------------------------------------------------------------
   IMPROVED SWIPE SYSTEM — velocity-based physics
   ---------------------------------------------------------------- */
.disc-card-flyout-like {
  animation: flyLike .45s ease forwards;
}
.disc-card-flyout-nope {
  animation: flyNope .45s ease forwards;
}
.disc-card-flyout-super {
  animation: flySuper .45s ease forwards;
}
@keyframes flyLike  { to { transform: translate(150vw, -20vh) rotate(30deg); opacity: 0; } }
@keyframes flyNope  { to { transform: translate(-150vw, -20vh) rotate(-30deg); opacity: 0; } }
@keyframes flySuper { to { transform: translate(0, -130vh) rotate(0deg); opacity: 0; } }

/* Card back-bounce */
@keyframes cardBounce { 0% {} 40% { transform: scale(1.03); } 100% { transform: none; } }

/* ----------------------------------------------------------------
   BOOST / ONLINE STATUS BADGES
   ---------------------------------------------------------------- */
.online-dot {
  display: inline-block;
  width: 10px; height: 10px;
  background: var(--green);
  border-radius: 50%;
  border: 2px solid var(--card);
  animation: pulse 2s ease infinite;
}
.boost-badge {
  display: inline-flex; align-items: center; gap: 3px;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff; font-size: .72rem; font-weight: 800;
  padding: .2rem .55rem; border-radius: 20px;
  box-shadow: 0 2px 8px rgba(139,92,246,.4);
}

/* ----------------------------------------------------------------
   LISTMATCH-STYLE "WHO LIKED YOU" BLUR CARDS
   ---------------------------------------------------------------- */
.liked-you-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.liked-you-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .85rem;
}
.liked-you-title {
  font-weight: 800; font-size: 1rem;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.liked-you-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem;
}
.liked-you-card {
  position: relative; border-radius: 12px; overflow: hidden;
  aspect-ratio: 3/4; cursor: pointer;
}
.liked-you-card img {
  width: 100%; height: 100%; object-fit: cover;
  filter: blur(18px) brightness(.7) saturate(.4);
  transform: scale(1.1);
  transition: filter .3s;
}
.liked-you-card.unlocked img { filter: none; transform: scale(1); }
.liked-you-card-lock {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: .35rem;
  background: rgba(0,0,0,.3);
}
.liked-you-card-lock span { font-size: 1.8rem; }
.liked-you-card-lock p { color: rgba(255,255,255,.8); font-size: .72rem; font-weight: 600; }
.liked-you-card.unlocked .liked-you-card-lock { display: none; }

/* ----------------------------------------------------------------
   PULL-TO-REFRESH
   ---------------------------------------------------------------- */
.ptr-indicator {
  display: flex; align-items: center; justify-content: center;
  height: 0; overflow: hidden;
  transition: height .2s ease;
  color: var(--text2); font-size: .88rem; gap: .5rem;
}
.ptr-indicator.visible { height: 48px; }
.ptr-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------
   IMPROVED TOAST
   ---------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 1rem);
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .6rem 1.2rem;
  border-radius: 20px;
  font-size: .9rem;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  animation: toastIn .25s ease;
  display: flex; align-items: center; gap: .5rem;
  max-width: calc(100vw - 2rem);
  white-space: nowrap;
}
@keyframes toastIn { from { opacity:0; transform: translateX(-50%) translateY(12px); } }
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-info    { border-left: 3px solid var(--primary); }

/* ----------------------------------------------------------------
   PERFORMANCE — will-change, contain
   ---------------------------------------------------------------- */
.post-card { contain: layout style; }
.disc-card { contain: layout style paint; }
#feedContainer { contain: layout; }

/* ----------------------------------------------------------------
   SMOOTH TRANSITIONS — page animations
   ---------------------------------------------------------------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
.post-card { animation: fadeInUp .25s ease both; }
.post-card:nth-child(1) { animation-delay: 0s; }
.post-card:nth-child(2) { animation-delay: .04s; }
.post-card:nth-child(3) { animation-delay: .08s; }
.post-card:nth-child(4) { animation-delay: .12s; }
.post-card:nth-child(n+5) { animation-delay: 0s; }

/* ----------------------------------------------------------------
   MEDIA QUERY IMPROVEMENTS
   ---------------------------------------------------------------- */
@media (max-width: 480px) {
  #cardStack { height: 460px; }
  .disc-name  { font-size: 1.25rem; }
  .disc-btn-like, .disc-btn-nope { width: 58px; height: 58px; font-size: 1.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ----------------------------------------------------------------
   IMPROVED COMPOSER — drag & drop zone
   ---------------------------------------------------------------- */
.composer-box.drag-over {
  border: 2px dashed var(--primary) !important;
  background: var(--primary-light) !important;
}
.composer-box.drag-over .composer-body-scroll::before {
  content: '📷 วางรูปได้เลย';
  display: flex; align-items: center; justify-content: center;
  position: absolute; inset: 0;
  font-size: 1.1rem; font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  z-index: 5; border-radius: 12px;
}

