/* Reels CSS split from original. */



/* Chat message media only — do NOT limit reels/call videos */
#messages img,
#messages video,
#private-messages img,
#private-messages video,
.media-grid img,
.media-grid video {
    max-width: 220px;
    border-radius: 10px;
}


/* Sheets */
.reels-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: min(88vh, 88dvh);
    background: #f7f7f7;
    border-radius: 18px 18px 0 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -12px 40px rgba(0,0,0,0.55);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.reels-sheet.hidden {
    display: none !important;
}

.reels-sheet-grab {
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: #ededed;
    margin: 8px auto 0;
}

.reels-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid #2a2a2a;
}

.reels-sheet-header button {
    background: transparent;
    border: none;
    color: #172033;
    font-size: 15px;
    cursor: pointer;
    min-width: 52px;
}

.reels-post-btn {
    color: #4fc3f7 !important;
    font-weight: 700;
}

.reels-source-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 16px 8px;
}

.reels-source-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 16px 18px;
    border-radius: 14px;
    border: 1px solid #2e2e2e;
    background: #f7f7f7;
    color: #172033;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}

.reels-source-btn i {
    width: 28px;
    text-align: center;
    color: #e91e63;
    font-size: 18px;
}

.reels-source-btn:active {
    background: #f7f7f7;
}

.reels-source-hint {
    text-align: center;
    color: #777;
    font-size: 12px;
    padding: 4px 16px 18px;
    margin: 0;
}

.reels-composer-body {
    overflow-y: auto;
    padding: 12px 14px 20px;
    -webkit-overflow-scrolling: touch;
}

.reels-preview-wrap {
    width: 100%;
    aspect-ratio: 9 / 14;
    max-height: 260px;
    background: #000;
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 14px;
}

.reels-preview-wrap {
    position: relative;
    width: 100%;
    height: 100%;
}
.reels-preview-wrap img,
.reels-preview-wrap video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;   /* ya cover */
}

.reels-field {
    display: block;
    font-size: 13px;
    color: #172033;
    margin-bottom: 14px;
}

.reels-field input[type="text"] {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 11px 12px;
    border-radius: 12px;
    border: 1px solid #333;
    background: #f7f7f7;
    color: #172033;
    box-sizing: border-box;
    font-size: 14px;
}

.reels-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.reels-chip {
    border: 1px solid #444;
    background: #f7f7f7;
    color: #172033;
    border-radius: 20px;
    padding: 7px 12px;
    font-size: 12px;
    cursor: pointer;
}

.reels-chip.active {
    background: linear-gradient(135deg, #f58529, #dd2a7b);
    border-color: transparent;
    color: #fff;
}

.reels-music-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
}

.reels-music-row {
    text-align: left;
    background: #f7f7f7;
    border: 1px solid #333;
    color: #172033;
    border-radius: 12px;
    padding: 11px 12px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

.reels-music-row.active {
    border-color: #e91e63;
    background: #f9f6f7;
}

.reels-volume-block input[type="range"] {
    width: 100%;
    margin: 6px 0 12px;
    accent-color: #e91e63;
}

.reels-vol-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #ccc;
}

.reels-comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
    min-height: 160px;
    max-height: 50vh;
}

.reels-comments-empty {
    color: #888;
    text-align: center;
    padding: 24px;
    font-size: 14px;
}

.reels-comment-row {
    padding: 9px 0;
    border-bottom: 1px solid #222;
    font-size: 13px;
    line-height: 1.4;
}

.reels-comment-row strong {
    margin-right: 6px;
    color: #172033;
}

.reels-comment-row span {
    color: #172033;
}

.reels-comment-input-row {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
    border-top: 1px solid #2a2a2a;
}

.reels-comment-input-row input {
    flex: 1;
    border-radius: 22px;
    border: 1px solid #333;
    background: #f7f7f7;
    color: #172033;
    padding: 11px 14px;
    font-size: 14px;
}

.reels-comment-input-row button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #f58529, #dd2a7b);
    color: #fff;
    cursor: pointer;
}

/* Always open the main Reels page as a true full-screen viewport. */
#reels-overlay {
    width: 100vw !important;
    max-width: none !important;
    height: 100dvh !important;
    max-height: none !important;
    inset: 0 !important;
}

@media (min-width: 768px) {
    /* Reels must use the entire viewport on desktop/tablet too. */
    #reels-overlay {
        max-width: none !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        width: 100vw !important;
        border-left: 0 !important;
        border-right: 0 !important;
    }
}


.reels-upload-bar {
    width: min(70vw, 240px);
    height: 6px;
    border-radius: 6px;
    background: rgba(255,255,255,0.2);
    overflow: hidden;
    margin-top: 4px;
}
#reels-upload-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #f58529, #dd2a7b);
    transition: width 0.15s ease;
}

.reels-profile-head {
    padding: 12px 16px 8px;
    text-align: center;
    border-bottom: 1px solid #2a2a2a;
}
.reels-profile-name { font-size: 18px; font-weight: 700; }
.reels-profile-count { font-size: 13px; color: #999; margin: 4px 0 12px; }
.reels-follow-btn {
    border: none; border-radius: 20px; padding: 8px 28px; font-weight: 700;
    font-size: 14px; cursor: pointer;
    background: linear-gradient(135deg, #f58529, #dd2a7b); color: #fff;
}
.reels-follow-btn.following { background: #ededed; border: 1px solid #444; color: #172033; }
.reels-profile-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
    padding: 2px; overflow-y: auto; max-height: 55vh;
}
.reels-profile-cell {
    position: relative; aspect-ratio: 9/16; background: #f7f7f7;
    overflow: hidden; cursor: pointer; border: none; padding: 0;
}
.reels-profile-cell video, .reels-profile-cell img {
    width: 100% !important; height: 100% !important; max-width: none !important;
    object-fit: cover !important; border-radius: 0 !important; display: block;
}
.reels-profile-cell .rpc-views {
    position: absolute; left: 4px; bottom: 4px; font-size: 10px;
    color: #172033; text-shadow: 0 1px 3px #000;
}
.reel-user { pointer-events: auto !important; cursor: pointer; }

.reels-preview-wrap img {
    object-fit: contain;   /* ya cover — try dono */
}


/* Kite Premium visual harmony for Reels */
.reels-page,.reels-container,.reels-feed,.reel-card,.reel-modal,.reels-profile,.reel-comments,.reel-actions{color:#172033;}
.reel-card,.reel-modal,.reels-profile{background:linear-gradient(145deg,rgba(255,255,255,.09),rgba(255,255,255,.035))!important;border:1px solid rgba(36,55,85,0.11)!important;box-shadow:0 24px 70px rgba(0,0,0,.28),inset 0 1px 0 rgba(255,255,255,.07)!important;backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);}
.reel-inline-follow{background:linear-gradient(135deg,#7c5cff,#20bfff)!important;border-color:rgba(255,255,255,.16)!important;color:#fff!important;box-shadow:0 8px 20px rgba(76,76,220,.22)!important;}


/* Private-chat Reels profile / Ping */
.private-reel-profile-btn,
.private-ping-btn { white-space: nowrap; }

.reels-follow-list-body {
    padding: 8px 12px 20px;
    overflow-y: auto;
    max-height: 65vh;
}
.reels-follow-user-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    margin: 3px 0;
    border: 0;
    border-radius: 12px;
    background: rgba(255,255,255,.06);
    color: inherit;
    text-align: left;
    cursor: pointer;
}
.reels-follow-user-row img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 44px;
}
.reels-follow-user-row span {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.reels-follow-user-row strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.reels-follow-user-row small { opacity: .7; margin-top: 2px; }

@media (max-width: 700px) {
    .private-reel-profile-btn,
    .private-ping-btn { padding: 7px 8px; }
    .private-reel-profile-btn span,
    .private-ping-btn span { display: none; }
}


/* Dedicated Followers / Following page */
#reels-follow-list.reels-sheet {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    z-index: 30002 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#reels-follow-list.reels-sheet.hidden { display:none !important; }
#reels-follow-list .reels-sheet-grab { display:none !important; }
#reels-follow-list .reels-follow-list-body {
    flex:1 1 auto;
    min-height:0;
    overflow-y:auto;
}

/* User Reels profile is a full-screen page, not a bottom sheet. */
#reels-profile.reels-sheet {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 30001 !important;
    background: #f6f7f9 !important;
}
#reels-profile .reels-sheet-grab { display:none !important; }
#reels-profile.reels-profile-on-top { z-index: 30003 !important; }
#reels-profile .reels-profile-grid {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none !important;
    overflow-y: auto;
}


/* Reels composer: give music choices enough vertical space so long track names stay visible. */
#reels-composer #reels-music-list .reels-chip {
    min-height: 48px !important;
    height: auto !important;
    padding: 12px 14px !important;
    line-height: 1.25 !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
}


/* Reels composer: full-screen so its header never overlaps the Reels page buttons. */
#reels-composer.reels-sheet {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    z-index: 40000 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f7f7f7 !important;
}
#reels-composer .reels-sheet-header {
    flex: 0 0 auto;
    position: relative;
    z-index: 2;
    background: #f7f7f7;
}
#reels-composer .reels-composer-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
}
/* Only the music list scrolls; the rest of the composer stays fixed. */
#reels-composer #reels-music-list {
    max-height: min(34vh, 300px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}
#reels-composer #reels-music-list .reels-chip {
    min-height: 44px !important;
    height: auto !important;
    box-sizing: border-box;
    padding: 9px 12px !important;
    line-height: 1.2 !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Music list gets a practical scroll area without hiding the audio controls below it. */
#reels-composer #reels-music-list {
    max-height: min(42vh, 360px) !important;
    overflow-y: auto !important;
}

/* Selected music uses the same clear accent treatment as selected filters. */
#reels-composer #reels-music-list .reels-chip.active {
    background: linear-gradient(135deg, #f58529, #dd2a7b) !important;
    border-color: transparent !important;
    color: #fff !important;
}


/* Reel composer order: Filters -> Voice/Volume -> Music */
#reels-composer .reels-volume-block {
  display: block !important;
  visibility: visible !important;
  position: relative;
  z-index: 2;
}

#reels-composer .reels-volume-block input[type="range"] {
  display: block !important;
  visibility: visible !important;
}

#reels-composer .reels-music-list {
  max-height: 240px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#reels-composer .reels-field {
  flex-shrink: 0;
}


/* Compact Reels controls and comment actions. */
.reel-side .reel-action { transform:scale(.86); transform-origin:center; }
.reels-comment-actions { display:flex; gap:5px; margin-top:4px; }
.reels-comment-actions button { font-size:10px !important; padding:3px 6px !important; min-height:24px !important; border-radius:7px !important; }
.reels-comment-input-row button { width:36px !important; height:36px !important; }
.reels-comment-input-row input { padding:8px 11px !important; font-size:13px !important; }
.reels-topbar button { transform:scale(.88); }
.reels-source-btn { padding:11px 14px !important; font-size:13px !important; }
#reels-composer .reels-sheet-header button { font-size:13px !important; min-width:44px !important; }
#reels-composer .reels-field { font-size:13px; }
#reels-composer .reels-uploading { position:relative; width:100%; margin:4px 0 10px; z-index:2; }


/* ===== Rich Share Cards: large thumbnail, URL hidden ===== */
.kite-rich-link-card{
  width:100% !important;
  max-width:520px !important;
  min-width:0;
  display:block !important;
  overflow:hidden !important;
  border-radius:16px !important;
  box-sizing:border-box !important;
}
.kite-rich-link-card .kite-link-preview-media{
  width:100% !important;
  height:180px !important;
  min-height:150px;
}
.kite-rich-link-card .kite-link-preview-media img{
  width:100% !important;
  height:100% !important;
  object-fit:cover !important;
}
.kite-rich-link-card .kite-link-url{
  display:none !important;
}
.kite-rich-link-card .kite-link-copy{
  padding:11px 13px 12px;
}
@media (max-width:480px){
  .kite-rich-link-card .kite-link-preview-media{
    height:170px !important;
  }
}

/* Reels media: images use the same viewport as videos. */
.reel-item .reel-media {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center center;
}

/* Image Reels use the exact same full-screen frame as video Reels.
   The image keeps its aspect ratio so it is never stretched or distorted. */
.reel-item .reel-image {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 100% !important;
  min-height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
  object-position: center center !important;
  z-index: 1 !important;
}


/* Reels player buttons: remove only the button/icon background */
#reels-overlay .reels-topbar button,
#reels-overlay .reel-action,
#reels-overlay .reel-action .reel-ico,
#reels-overlay .reel-user,
#reels-overlay .reel-inline-follow {
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}


/* Upload source/composer: the Reels feed underneath must stay completely fixed. */
#reels-overlay:has(#reels-source-sheet:not(.hidden)) #reels-feed,
#reels-overlay:has(#reels-composer:not(.hidden)) #reels-feed {
    overflow-y: hidden !important;
    overscroll-behavior: none !important;
    touch-action: none !important;
    scroll-behavior: auto !important;
}
#reels-source-sheet,
#reels-composer {
    overscroll-behavior: contain;
    touch-action: pan-y;
}


/* Reels video trim controls */
.reels-trim-panel {
    margin: 0 0 14px;
    padding: 14px;
    border: 1px solid #333;
    border-radius: 14px;
    background: #f7f7f7;
}
.reels-trim-panel.hidden { display: none !important; }
.reels-trim-title {
    color: #172033;
    font-weight: 700;
    font-size: 15px;
}
.reels-trim-hint {
    color: #999;
    font-size: 12px;
    margin: 5px 0 12px;
}
.reels-trim-row {
    margin: 10px 0;
}
.reels-trim-row > span {
    display: flex;
    justify-content: space-between;
    color: #172033;
    font-size: 12px;
    margin-bottom: 5px;
}
.reels-trim-row strong { color: #172033; }
.reels-trim-row input[type="range"] {
    width: 100%;
    margin: 0;
}
.reels-trim-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 12px;
}
.reels-trim-actions > span {
    flex: 1;
    color: #aaa;
    font-size: 12px;
}
.reels-trim-actions button {
    border: 1px solid #444;
    border-radius: 9px;
    background: #f7f7f7;
    color: #172033;
    padding: 8px 10px;
    font-size: 12px;
}
#reels-trim-apply {
    background: linear-gradient(135deg,#7c5cff,#20bfff);
    border-color: transparent;
    font-weight: 700;
}
.reels-trim-actions button:disabled {
    opacity: .5;
}
.reels-trim-status {
    color: #8f8f8f;
    font-size: 11px;
    margin-top: 8px;
}

/* Upload progress stays visible at the top of the Reels feed after composer closes. */
#reels-feed > .reels-uploading-feed {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  margin: 0;
  padding: 10px 14px;
  background: rgba(12, 12, 12, .94);
  box-sizing: border-box;
}

/* Upload lock: composer remains visible while all its controls are disabled. */
#reels-composer.reels-composer-busy button:disabled,
#reels-composer.reels-composer-busy input:disabled,
#reels-composer.reels-composer-busy textarea:disabled,
#reels-composer.reels-composer-busy select:disabled {
  opacity: .55 !important;
  cursor: wait !important;
}
#reels-composer .reels-uploading:not(.hidden) {
  display: flex !important;
  position: sticky;
  top: 0;
  z-index: 20;
}

/* ===== Reels performance + camera additions ===== */
.reel-item { contain: layout paint style; }
.reels-camera-bigcount { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:120px; font-weight:800; color:#fff; text-shadow:0 2px 18px rgba(0,0,0,.7); pointer-events:none; }
.reels-camera-filters { display:flex; gap:8px; overflow-x:auto; padding:10px 12px 0; scrollbar-width:none; flex:0 0 auto; }
.reels-camera-filters::-webkit-scrollbar { display:none; }
.reels-camera-filters button { flex:0 0 auto; padding:6px 12px; border-radius:16px; border:1px solid #666; background:#222; color:#fff; font-size:12px; font-weight:700; }
.reels-camera-filters button.active { background:#fff; color:#000; border-color:#fff; }
.reels-camera-actions { gap:10px !important; }
.reels-camera-actions button { min-width:0 !important; padding:0 16px; }
.reels-camera-actions [data-camera-timer] { min-width:72px !important; }
