:root {
      --bg: #f8f9fa; --card: #ffffff; --sidebar-bg: #ffffff; --text: #212529; --muted: #6c757d; --accent: #007bff; --accent-dark: #0056b3; --danger: #e74c3c; --success: #28a745; --ring: rgba(0, 123, 255, 0.25); --header-bg: rgba(255, 255, 255, 0.85); --border: #dee2e6; --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.07); --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    }
    [data-theme="dark"] {
      --bg: #121212; --card: #1e1e1e; --sidebar-bg: #1e1e1e; --text: #e0e0e0; --muted: #9e9e9e; --accent: #64b5f6; --accent-dark: #2196f3; --danger: #e57373; --success: #81c784; --header-bg: rgba(30, 30, 30, 0.85); --border: #424242; --ring: rgba(100, 181, 246, 0.3);
    }
    *, *::before, *::after { box-sizing: border-box; }
    html { -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; }
    body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; margin: 0; transition: background .3s, color .3s; }
    .hidden { display: none !important; }
    .app-layout { display: flex; transition: margin-left .3s ease; }
    .sidebar { width: 260px; background: var(--sidebar-bg); border-right: 1px solid var(--border); position: fixed; top: 0; left: -260px; bottom: 0; z-index: 1200; display: flex; flex-direction: column; transition: left .3s ease; box-shadow: var(--shadow); }
    .sidebar.open { left: 0; }
    .content-wrapper { flex: 1; display: flex; flex-direction: column; min-height: 100vh; padding-bottom: 80px; }
    main, #chat-view { padding: 1rem; flex: 1; }
    .page-title { font-size: 2rem; font-weight: 700; margin-bottom: 1.5rem; letter-spacing: -0.5px; }
    .backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1100; opacity: 0; pointer-events: none; transition: opacity .3s ease; }
    .backdrop.active { opacity: 1; pointer-events: auto; }
    .app-header { background: var(--header-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1000; padding: 0.75rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
    .header-left, .header-right { display: flex; align-items: center; gap: .5rem; transition: opacity 0.3s ease; }
    .header-search-container { flex: 1; display: flex; justify-content: flex-end; }
    #header-search-input { width: 0; padding: 0; border: none; background: transparent; outline: none; font-size: 1rem; color: var(--text); transition: all 0.4s ease-in-out; }
    .app-header.search-active #header-search-input { width: 100%; padding: 0.5rem; border-bottom: 2px solid var(--accent); }
    .app-header.search-active .header-left, .app-header.search-active .header-right .header-icon-btn:not(#search-toggle) { opacity: 0; pointer-events: none; }
    #search-toggle .fa-times { display: none; }
    .app-header.search-active #search-toggle .fa-search { display: none; }
    .app-header.search-active #search-toggle .fa-times { display: block; }
    .header-icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer; border: none; transition: all .2s; }
    .header-icon-btn:hover { background: var(--border); color: var(--text); }
    
    #notifications-toggle.subscribed { color: var(--success); }
    
    .sidebar-header { padding: 1.5rem 1rem; border-bottom: 1px solid var(--border); }
    .sidebar-logo { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--text); }
    .sidebar-logo img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow); }
    .sidebar-logo-text h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.2; margin: 0; }
    .sidebar-logo-text p { font-size: .85rem; color: var(--muted); line-height: 1.2; margin: 0; }
    .sidebar-menu { flex: 1; padding: 1rem; overflow-y: auto; }
    .menu-heading { font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; padding: 0 .75rem; margin: 1.5rem 0 .75rem; }
    .menu-item { display: flex; align-items: center; gap: .85rem; padding: .75rem; border-radius: 8px; font-weight: 500; text-decoration: none; color: var(--text); transition: background .2s, color .2s; cursor: pointer; }
    .menu-item i { width: 20px; text-align: center; color: var(--muted); transition: color .2s; font-size: 0.95rem; }
    .menu-item:hover { background: var(--border); }
    .menu-item.active { background: var(--accent); color: white; font-weight: 600; }
    .menu-item.active i { color: white; }
    .bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: 65px; background: var(--header-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); display: flex; justify-content: space-around; z-index: 1000; box-shadow: 0 -5px 20px rgba(0,0,0,0.05); }
    .nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); flex: 1; padding: 0.5rem 0; cursor: pointer; transition: color 0.2s ease, transform 0.1s ease; }
    .nav-item:active { transform: scale(0.92); }
    .nav-item i { font-size: 1.3rem; margin-bottom: 2px; }
    .nav-item .nav-text { font-size: 0.75rem; font-weight: 500; }
    .nav-item.active { color: var(--accent); }
    #post-grid { display: grid; gap: 1rem; }
    .post-card { background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); transition: transform .25s ease, box-shadow .25s ease; cursor: pointer; position: relative; }
    .post-card-img-wrapper { position: relative; }
    .post-card-img { width: 100%; height: 200px; object-fit: cover; display: block; }
    .post-card-content { padding: 1.25rem; }
    .post-card-category { background: var(--accent); color: white; padding: 5px 12px; border-radius: 99px; font-weight: 600; font-size: 11px; display: inline-block; margin-bottom: 0.75rem; }
    .post-card-title { font-size: 1.2rem; font-weight: 600; margin-bottom: 0.25rem; }
    .post-card-desc { color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
    .wishlist-btn { position: absolute; top: 0.75rem; right: 0.75rem; width: 40px; height: 40px; border-radius: 50%; background-color: rgba(0,0,0,0.4); color: white; border: none; cursor: pointer; display: grid; place-items: center; font-size: 1.1rem; transition: transform 0.2s ease, color 0.2s ease; }
    .wishlist-btn:hover { transform: scale(1.1); }
    .wishlist-btn.wishlisted { color: var(--danger); }
    .wishlist-btn .fa-solid { display: none; }
    .wishlist-btn.wishlisted .fa-regular { display: none; }
    .wishlist-btn.wishlisted .fa-solid { display: inline-block; animation: heartbeat 0.5s ease; }
    @keyframes heartbeat { 0% {transform: scale(1);} 50% {transform: scale(1.3);} 100% {transform: scale(1);} }
    .edit-btn { position: absolute; top: 0.75rem; left: 0.75rem; width: 40px; height: 40px; border-radius: 50%; background-color: rgba(0,0,0,0.4); color: white; border: none; cursor: pointer; display: grid; place-items: center; font-size: 1rem; transition: transform 0.2s ease, background-color 0.2s ease; z-index: 5; }
    .edit-btn:hover { transform: scale(1.1); background-color: rgba(0, 123, 255, 0.8); }
    
    .delete-btn { 
      position: absolute; 
      top: 0.75rem; 
      left: 4.25rem; /* (40px tombol edit) + (0.75rem jarak) */
      width: 40px; 
      height: 40px; 
      border-radius: 50%; 
      background-color: rgba(0,0,0,0.4); 
      color: white; 
      border: none; 
      cursor: pointer; 
      display: grid; 
      place-items: center; 
      font-size: 1rem; 
      transition: all 0.2s ease; 
      z-index: 5; 
    }
    .delete-btn:hover { 
      transform: scale(1.1); 
      background-color: var(--danger); 
    }

    .skeleton-card { background: var(--card); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
    .skeleton-img { height: 200px; background: var(--border); }
    .skeleton-content { padding: 1.25rem; }
    .skeleton-line { height: 1em; border-radius: 4px; background: var(--border); margin-bottom: .75rem; }
    .shimmer { position: relative; overflow: hidden; }
    .shimmer::after { content: ''; position: absolute; top: 0; left: -150%; width: 100%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent); animation: shimmer 1.5s infinite; }
    [data-theme="dark"] .shimmer::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent); }
    @keyframes shimmer { 100% { left: 150%; } }
    #post-modal-wrapper, #auth-modal-wrapper, #request-modal-wrapper { position: fixed; inset: 0; z-index: 1300; opacity: 0; pointer-events: none; transition: opacity .3s ease; }
    #post-modal-wrapper.open, #auth-modal-wrapper.open, #request-modal-wrapper.open { opacity: 1; pointer-events: auto; }
    .modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
    .modal-container { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 1rem; }
    .modal-content { background: var(--card); width: 100%; max-width: 520px; border-radius: 16px; box-shadow: var(--shadow-lg); transform: scale(0.95); transition: transform .3s ease; display: flex; flex-direction: column; max-height: 90vh; }
    #post-modal-wrapper.open .modal-content, #auth-modal-wrapper.open .modal-content, #request-modal-wrapper.open .modal-content { transform: scale(1); }
    #post-modal-header { position: relative; }
    #post-modal-img { width: 100%; height: 220px; object-fit: cover; display: block; }
    #post-modal-close { position: absolute; top: 0.75rem; right: 0.75rem; background: rgba(0,0,0,0.4); color: white; z-index: 10; }
    #post-modal-close:hover { background: rgba(0,0,0,0.6); }
    .post-details { padding: 1.5rem; }
    #modal-category { background: var(--accent); color: white; padding: 5px 12px; border-radius: 99px; font-weight: 600; font-size: 11px; display: inline-block; margin-bottom: 0.75rem; }
    #modal-title { font-size: 1.5rem; font-weight: 700; margin: 0 0 0.5rem; }
    #modal-desc { color: var(--muted); font-size: 0.95rem; line-height: 1.6; margin: 0 0 1.5rem; }
    .download-section h4 { margin: 0 0 1rem; font-size: 0.9rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
    .download-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.75rem; }
    .btn-download { display: flex; align-items: center; justify-content: center; text-decoration: none; padding: 0.75rem; border-radius: 8px; font-weight: 600; transition: all .2s ease; }
    .btn-download i { margin-right: 0.5rem; font-size: 1.1rem; }
    .btn-mediafire { background-color: #0099e5; color: white; }
    .btn-mediafire:hover { background-color: #0077b2; transform: translateY(-2px); }
    .btn-gofile { background-color: #215ff3; color: white; }
    .btn-gofile:hover { background-color: #1a4ccc; transform: translateY(-2px); }
    
    .btn-dynamic {
      background-color: var(--muted);
      color: var(--text);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    [data-theme="dark"] .btn-dynamic {
      color: var(--bg);
    }
    .btn-dynamic:hover {
      background-color: var(--accent);
      color: white;
      transform: translateY(-2px);
    }

    #auth-container input, #auth-container textarea, #auth-container select, #request-container input, #request-container textarea, #request-container select { width: 100%; padding: 0.75rem; margin-bottom: 1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 1rem; }
    #auth-container button, #request-container button { width: 100%; padding: 0.75rem; border-radius: 8px; border: none; background: var(--accent); color: white; font-weight: 600; cursor: pointer; transition: background .2s; }
    #auth-container button:hover, #request-container button:hover { background: var(--accent-dark); }
    #auth-container #logout-btn { background-color: var(--danger); }
    #auth-container .admin-nav-link { display: block; text-align: center; margin-bottom: 1.5rem; color: var(--accent); font-weight: 500; cursor: pointer; }
    #auth-container .admin-nav-link:hover { text-decoration: underline; }
    #auth-container p a { color: var(--accent); text-decoration: none; font-weight: 500; }
    #auth-container p a:hover { text-decoration: underline; }
    .profile-header { display: flex; flex-direction: column; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
    .profile-avatar-wrapper { position: relative; }
    .profile-avatar { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; border: 3px solid var(--border); }
    #avatar-upload-label { position: absolute; bottom: 0; right: 0; width: 32px; height: 32px; background: var(--accent); color: white; border-radius: 50%; display: grid; place-items: center; cursor: pointer; border: 2px solid var(--card); }
    #avatar-upload-label:hover { background: var(--accent-dark); }
    
    .admin-actions-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
      gap: 0.75rem;
      margin-top: 1.5rem;
      margin-bottom: 0.75rem;
    }
    .admin-action-btn {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.35rem;
      background-color: transparent; 
      border: none;
      border-radius: 8px;
      padding: 0.75rem 0.5rem;
      cursor: pointer;
      transition: all 0.2s ease;
      color: var(--muted); 
      font-size: 0.75rem;
      font-weight: 500;
      line-height: 1.2;
      text-align: center;
    }
    .admin-action-btn:hover {
      color: var(--accent); 
      background-color: var(--bg); 
    }
    .admin-action-btn i {
      font-size: 1.25rem;
      width: 30px; 
      text-align: center;
      margin-bottom: 2px;
    }

    #logout-btn {
        background-color: var(--danger) !important;
        margin-top: 0.5rem;
    }

    #dynamic-links-container .link-entry {
      display: flex;
      gap: 0.5rem;
      margin-bottom: 0.75rem;
      align-items: center;
    }
    #dynamic-links-container .link-entry input[type="text"] {
      width: 40%;
      margin-bottom: 0;
      flex-shrink: 1;
    }
    #dynamic-links-container .link-entry input[type="url"] {
      width: 60%;
      margin-bottom: 0;
      flex: 1;
    }
    #auth-container .remove-link-btn {
    padding: 0.5rem 0.75rem;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1;
    width: auto;
    }
    #add-link-btn {
      width: auto;
      background: var(--success);
      padding: 0.5rem 1rem;
      font-size: 0.9rem;
      margin-top: -0.5rem;
      margin-bottom: 1rem;
    }

    #auth-container {
        overflow-y: auto;
        flex: 1;
        padding: 1.5rem;
    }
    #user-list-container {
        padding-right: 5px;
    }
    
    .user-management-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
    .user-management-item { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem; background-color: var(--bg); border-radius: 8px; border: 1px solid var(--border); }
    .user-management-info { display: flex; flex-direction: column; }
    .user-management-info .nickname { font-weight: 600; }
    .user-management-info .email { font-size: 0.85rem; color: var(--muted); }
    .user-management-role select { padding: 0.3rem 0.5rem; border-radius: 6px; border: 1px solid var(--border); background-color: var(--card); color: var(--text); }
    #notification-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
    .toast { background: var(--card); color: var(--text); padding: 12px 20px; border-radius: 8px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 12px; border-left: 5px solid; transition: transform 0.3s ease, opacity 0.3s ease; transform: translateX(calc(100% + 20px)); }
    .toast.show { transform: translateX(0); }
    .toast.hide { transform: translateX(calc(100% + 20px)); opacity: 0; }
    .toast i { font-size: 1.2rem; }
    .toast.success { border-color: var(--success); }
    .toast.success i { color: var(--success); }
    .toast.error { border-color: var(--danger); }
    .toast.error i { color: var(--danger); }
    .comment-section { padding: 0 1.5rem 1.5rem; border-top: 1px solid var(--border); flex: 1; overflow-y: auto; }
    .comment-section h4 { margin: 1.5rem 0 1rem; font-size: 0.9rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
    #comment-list { display: flex; flex-direction: column; gap: 1rem; }
    .comment-item { display: flex; gap: .75rem; }
    .comment-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; margin-top: 2px; flex-shrink: 0; }
    .comment-content { flex: 1; }
    .comment-header { display: flex; align-items: center; gap: .5rem; margin-bottom: 2px; }
    .comment-author { font-weight: 600; font-size: .9rem; }
    .comment-date { font-size: .75rem; color: var(--muted); margin-left: auto; }
    .comment-body { font-size: .95rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
    #comment-form { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: 1.5rem; }
    #comment-form textarea { flex: 1; resize: vertical; min-height: 40px; padding: 0.5rem 0.75rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: .95rem; }
    #comment-form button { padding: 0.5rem 1rem; border-radius: 8px; border: none; background: var(--accent); color: white; font-weight: 600; cursor: pointer; transition: background .2s; }
    #comment-form button:hover { background: var(--accent-dark); }
    #comment-login-prompt, .chat-login-prompt { text-align: center; padding: 2rem 1rem; }
    #comment-login-prompt i, .chat-login-prompt i { font-size: 2.5rem; color: var(--muted); margin-bottom: 1rem; }
    #comment-login-prompt h3, .chat-login-prompt h3 { margin-top: 0; }
    #comment-login-prompt p, .chat-login-prompt p { color: var(--muted); }
    #comment-login-prompt a { color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: none; }
    #comment-login-prompt a:hover { text-decoration: underline; }
    .role-badge { font-size: .65rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; text-transform: uppercase; line-height: 1; vertical-align: middle; }
    .role-badge.admin { background-color: var(--danger); color: white; }
    .role-badge.moderator { background-color: var(--accent); color: white; }
    .role-badge.user { background-color: var(--border); color: var(--text); }
    .request-management-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
    .request-management-item { display: flex; flex-direction: column; padding: 1rem; background-color: var(--bg); border-radius: 8px; border: 1px solid var(--border); }
    .request-management-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem; }
    .request-management-title { font-weight: 600; margin: 0; }
    .request-management-category { font-size: 0.8rem; background-color: var(--accent); color: white; padding: 3px 8px; border-radius: 5px; }
    .request-management-user { font-size: 0.85rem; color: var(--muted); margin: 0.25rem 0 0.75rem; }
    .request-management-desc { font-size: 0.9rem; margin-bottom: 1rem; }
    .request-management-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
   #auth-container .request-management-actions button { 
  width: auto; 
  padding: 0.3rem 0.8rem; 
  font-size: 0.8rem; 
}
  #auth-container .request-management-actions .delete-btn { 
  background-color: var(--danger); 
  position: relative;
  top: auto;
  left: auto;
  z-index: auto;
}


    #chat-view { padding: 0; display: flex; justify-content: center; }
    #chat-view-container { display: flex; flex-direction: column; height: calc(100vh - 70px); max-width: 900px; width: 100%; background: var(--card); }
    .chat-messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; scroll-behavior: smooth; }
    .chat-message { display: flex; gap: 1rem; max-width: 75%; align-items: flex-end; user-select: none; -webkit-user-select: none; }
    .chat-message.current-user { align-self: flex-end; flex-direction: row-reverse; }
    .chat-message .message-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; box-shadow: var(--shadow); }
    .message-content { display: flex; flex-direction: column; width: 100%; }
    .message-bubble { position: relative; padding: 0.75rem 1.25rem; border-radius: 18px; background: var(--bg); box-shadow: var(--shadow); line-height: 1.5; }
    .chat-message.current-user .message-bubble { background: var(--accent); color: white; cursor: pointer; }
    .message-meta { display: flex; justify-content: space-between; align-items: center; padding: 0 .5rem; margin-bottom: 4px; }
    .chat-message.current-user .message-meta { flex-direction: row-reverse; }
    .message-author { font-weight: 600; font-size: .8rem; }
    .message-timestamp { font-size: .7rem; color: var(--muted); }
    .chat-message.current-user .message-author { color: var(--text); opacity: 0.9; }
    .message-text { margin: 0; white-space: pre-wrap; word-wrap: break-word; }
    .message-edited-tag { font-size: 0.7rem; color: var(--muted); opacity: 0.8; margin-left: 5px; }
    .chat-message.current-user .message-edited-tag { color: white; }
    #chat-form { display: flex; gap: .75rem; padding: 1rem; border-top: 1px solid var(--border); background-color: var(--sidebar-bg); }
    #chat-form input { flex: 1; padding: 0.85rem 1.25rem; border-radius: 99px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 1rem; }
    #chat-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); outline: none; }
    #chat-form button { width: 50px; height: 50px; border-radius: 50%; border: none; background: var(--accent); color: white; font-weight: 600; cursor: pointer; transition: all .2s; font-size: 1.1rem; flex-shrink: 0; }
    #chat-form button:hover { background: var(--accent-dark); transform: scale(1.05); }

    .message-context-menu { position: fixed; z-index: 1500; background: var(--card); border-radius: 8px; box-shadow: var(--shadow-lg); overflow: hidden; display: none; }
    .context-menu-btn { padding: 0.75rem 1.25rem; background: none; border: none; color: var(--text); display: flex; align-items: center; gap: 0.75rem; width: 100%; text-align: left; cursor: pointer; }
    .context-menu-btn:hover { background: var(--bg); }
    .context-menu-btn.delete { color: var(--danger); }
    
    .message-edit-form { display: flex; flex-direction: column; gap: 0.5rem; }
    .message-edit-form textarea { width: 100%; resize: vertical; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem; }
    .message-edit-form .edit-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
    .message-edit-form button { background: var(--accent); color: white; border: none; padding: 0.4rem 0.8rem; border-radius: 6px; cursor: pointer; }
    .message-edit-form .cancel-btn { background: var(--muted); }

    @media (min-width: 768px) {
      #chat-view-container { height: calc(100vh - 85px); border: 1px solid var(--border); border-radius: 16px; margin: 1rem 0; box-shadow: var(--shadow-lg); }
      .bottom-nav, #menu-toggle, .backdrop { display: none; }
      .app-layout { margin-left: 260px; }
      .sidebar { left: 0; box-shadow: none; }
      main { padding: 2rem; }
      #post-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }
    }
    @media (hover: hover) { .post-card:hover { transform: translateY(-5px) scale(1.02); box-shadow: var(--shadow-lg); } }

    /* --- CSS POPUP --- */
    #welcome-popup-wrapper {
      position: fixed;
      inset: 0;
      z-index: 2100;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 1rem;
      opacity: 0;
      pointer-events: none;
      transition: opacity .3s ease;
    }
    #welcome-popup-wrapper.open {
      opacity: 1;
      pointer-events: auto;
    }
    #welcome-popup-wrapper .popup-backdrop {
      position: absolute;
      inset: 0;
      background: rgba(0,0,0,0.5);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      cursor: pointer;
    }
    #welcome-popup-wrapper .popup-content {
      position: relative;
      background: var(--card);
      border-radius: 16px;
      box-shadow: var(--shadow-lg);
      width: 100%;
      max-width: 320px; 
      overflow: hidden;
      transform: scale(0.9);
      transition: transform .3s ease;
    }
    #welcome-popup-wrapper.open .popup-content {
      transform: scale(1);
    }
    #welcome-popup-wrapper .popup-content img {
      width: 100%;
      height: auto;
      display: block;
    }
    #welcome-popup-wrapper .popup-close-btn {
      position: absolute;
      top: 0.75rem;
      right: 0.75rem;
      width: 36px;
      height: 36px;
      border-radius: 50%;
      border: none;
      background: rgba(0,0,0,0.4);
      color: white;
      font-size: 1.5rem;
      font-weight: 700;
      line-height: 36px;
      text-align: center;
      cursor: pointer;
      display: grid;
      place-items: center;
      z-index: 10;
      transition: all .2s;
    }
    #welcome-popup-wrapper .popup-close-btn:hover {
      background: rgba(0,0,0,0.7);
      transform: scale(1.1);
    }
    
.image-preview {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
}
.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.image-preview .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--muted);
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: white;
  padding: 0.6rem 1.2rem;
  border-radius: 40px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: 0.2s;
  border: none;
}
.btn-upload:hover {
  background: var(--accent-dark);
  transform: scale(1.02);
}

.link-entry {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.75rem;
  align-items: center;
  background: transparent;
  padding: 0.5rem 0;
  border: none;
  margin-bottom: 0.5rem;
}
.link-entry input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}
.link-entry .remove-link-btn {
  background: var(--danger);
  color: white;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.link-entry .remove-link-btn:hover {
  filter: brightness(0.9);
}

.checkbox-group {
  margin: 1rem 0;
  display: flex;
  align-items: center;
}

.checkbox-label {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  cursor: pointer;
  font-weight: normal;
  color: var(--text);
  white-space: nowrap;
}

.checkbox-label input {
  width: 18px !important;
  height: 18px !important;
  margin: 0 !important;
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-label span {
  display: inline-block;
  line-height: 1.2;
}

@media (max-width: 640px) {
  .link-entry {
    flex-wrap: wrap;
  }
  .link-entry input {
    width: 100%;
  }
  .image-preview {
    width: 100%;
    max-width: 200px;
    height: auto;
    aspect-ratio: 1 / 1;
  }
  .checkbox-label {
    white-space: normal;
  }
}
#post-detail-view {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
#post-detail-view.hidden { display: none; }

#detail-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem 0;
}
#detail-back-btn:hover { text-decoration: underline; }

.detail-header {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.detail-header img {
  width: 100%;
  max-height: 350px;
  object-fit: cover;
  display: block;
}
.detail-body {
  padding: 0.5rem 0;
}
.detail-body .category-badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 0.3rem 0.9rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.detail-body h2 {
  font-size: 1.8rem;
  margin: 0.5rem 0 1rem;
}
.detail-body .description {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 1.5rem;
}

/* Media dalam deskripsi (kecil, bisa diklik) */
.description img,
.description video {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0.5rem 0;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.description img:hover,
.description video:hover {
  transform: scale(1.02);
}

/* Link download */
.detail-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.5rem 0;
}
.detail-downloads .btn-download {
  /* gunakan style btn-download yang sudah ada */
}

/* Komentar di halaman detail */
.detail-comments {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

/* ------------------ LIGHTBOX ------------------ */
.media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.media-lightbox.open {
  opacity: 1;
  pointer-events: auto;
}
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
}
.lightbox-container {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  z-index: 1;
}
.lightbox-container img,
.lightbox-container video {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.lightbox-close {
  position: absolute;
  top: -1rem;
  right: -1rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: white;
  border: none;
  font-size: 1.6rem;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: transform 0.2s;
}
.lightbox-close:hover {
  transform: scale(1.1);
}

/* Responsif */
@media (max-width: 640px) {
  .detail-body h2 {
    font-size: 1.5rem;
  }
  .detail-header img {
    max-height: 250px;
  }
}
.media-slider {
  position: relative;
  margin: 1rem 0;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
}
.slider-viewport {
  width: 100%;
  overflow: hidden;
}
.slider-track {
  display: flex;
  transition: transform 0.3s ease;
}
.slide {
  flex: 0 0 100%;
  text-align: center;
  display: none;
}
.slide.active {
  display: block;
}
.slide img, .slide video {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: 0;
}
.slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.4);
  color: white;
  border: none;
  font-size: 1.2rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slider-btn.prev { left: 10px; }
.slider-btn.next { right: 10px; }
.slider-btn:hover { background: rgba(0,0,0,0.7); }

.slider-dots {
  text-align: center;
  padding: 0.5rem;
}
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin: 0 5px;
  background: var(--muted);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}
.dot.active {
  background: var(--accent);
}

/* Styling untuk preview di form */
.media-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 8px;
}
.media-entry-preview {
  width: 80px;
  height: 60px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-entry-preview img, .media-entry-preview video {
  object-fit: cover;
}
.placeholder-small {
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.btn-choose-media, .btn-remove-media {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}
.btn-remove-media {
  background: var(--danger);
}
    /* --- AKHIR CSS POPUP --- */

  
  
    #debug-console {
      position: fixed;
      bottom: 0;
      left: 0;
      width: 100%;
      max-height: 150px;
      background: rgba(20, 0, 0, 0.9);
      border-top: 2px solid var(--danger);
      color: #ffaaaa;
      font-family: monospace;
      font-size: 11px;
      z-index: 99999;
      overflow-y: auto;
      padding: 5px;
      box-sizing: border-box;
    }
    #debug-console pre {
      margin: 0 0 5px 0;
      padding-bottom: 5px;
      border-bottom: 1px dashed #555;
      white-space: pre-wrap;
      word-break: break-all;
    }
    /* --------------------------------- */